mirror of
https://github.com/marko-js/marko.git
synced 2026-02-01 16:07:13 +00:00
w-id migration key only for components (#1217)
* only add id:scoped for html/dynamic tags
This commit is contained in:
parent
9684fdda39
commit
edd7d8e9b0
@ -9,6 +9,9 @@ module.exports = function migrate(el, context) {
|
||||
);
|
||||
|
||||
el.setAttributeValue("key", attr.value);
|
||||
if (!el.hasAttribute("id")) el.setAttributeValue("id:scoped", attr.value);
|
||||
const isHTML = el.tagDef && el.tagDef.html;
|
||||
const isDynamic = Boolean(el.rawTagNameExpression);
|
||||
if (!el.hasAttribute("id") && (isHTML || isDynamic))
|
||||
el.setAttributeValue("id:scoped", attr.value);
|
||||
el.removeAttribute(attr.name);
|
||||
};
|
||||
|
||||
@ -12,8 +12,7 @@ function render(input, out, __component, component, state) {
|
||||
var data = input;
|
||||
|
||||
marko_dynamicTag(input, {
|
||||
x: 1,
|
||||
id: __component.elId("hi")
|
||||
x: 1
|
||||
}, out, __component, "hi");
|
||||
}
|
||||
|
||||
|
||||
@ -0,0 +1,3 @@
|
||||
{
|
||||
"@foo": "string"
|
||||
}
|
||||
0
test/migrate/fixtures/w-id/components/test.marko
Normal file
0
test/migrate/fixtures/w-id/components/test.marko
Normal file
@ -2,3 +2,5 @@
|
||||
|
||||
<div key="a" id:scoped="a"/>
|
||||
<div key="b" id:scoped="b"/>
|
||||
<test key="c"/>
|
||||
<${tag} key="d" id:scoped="d"/>
|
||||
@ -1,2 +1,4 @@
|
||||
<div w-id="a"/>
|
||||
<div w-id="b"/>
|
||||
<div w-id="b"/>
|
||||
<test w-id="c"/>
|
||||
<${tag} w-id="d"/>
|
||||
Loading…
x
Reference in New Issue
Block a user