w-id migration key only for components (#1217)

* only add id:scoped for html/dynamic tags
This commit is contained in:
Michael Rawlings 2019-01-03 09:55:07 -08:00 committed by Dylan Piercey
parent 9684fdda39
commit edd7d8e9b0
6 changed files with 13 additions and 4 deletions

View File

@ -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);
};

View File

@ -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");
}

View File

@ -0,0 +1,3 @@
{
"@foo": "string"
}

View 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"/>

View File

@ -1,2 +1,4 @@
<div w-id="a"/>
<div w-id="b"/>
<div w-id="b"/>
<test w-id="c"/>
<${tag} w-id="d"/>