Fix issue when using getEls with repeated id in a split component (#1343)

This commit is contained in:
Dylan Piercey 2019-05-29 11:39:34 -07:00 committed by GitHub
parent 4a73060bc6
commit e729b89b1e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 14 additions and 1 deletions

View File

@ -4,6 +4,6 @@ var FLAG_WILL_RERENDER_IN_BROWSER = 1;
module.exports = function markoKeyAttr(key, componentDef) {
if ((componentDef.___flags & FLAG_WILL_RERENDER_IN_BROWSER) === 0) {
return key + " " + componentDef.id;
return componentDef.___nextKey(key) + " " + componentDef.id;
}
};

View File

@ -1,3 +1,9 @@
<div.split-component>
<button key="button">Click me</button>
<ul>
<for|i| from=1 to=3>
<li key="li[]">${i}</li>
</for>
</ul>
</div>

View File

@ -6,5 +6,12 @@ describe(path.basename(__dirname), function() {
var splitComponent = window.splitComponent;
expect(splitComponent.getEl("button") != null).to.equal(true);
expect(splitComponent.getEl("button").nodeName).to.equal("BUTTON");
expect(splitComponent.getEls("li").length).to.equal(3);
expect(splitComponent.getEls("li").map(el => el.textContent)).to.eql([
"1",
"2",
"3"
]);
});
});