-
Notifications
You must be signed in to change notification settings - Fork 643
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #900 from marko-js/issue-899
Fixes #899 - Repeated elements with no assigned key are not added to lookup when rendered on the server
- Loading branch information
Showing
4 changed files
with
93 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
11 changes: 11 additions & 0 deletions
11
.../autotests/components-pages/repeated-list-items-unkeyed/components/list-items/index.marko
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
class { | ||
onMount() { | ||
window.listItemsComponent = this; | ||
} | ||
} | ||
|
||
<ul key="root"> | ||
<li for(option in input.options)> | ||
<a>${option}</a> | ||
</li> | ||
</ul> |
28 changes: 28 additions & 0 deletions
28
test/autotests/components-pages/repeated-list-items-unkeyed/template.marko
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
lasso-page dependencies=input.browserDependencies lasso=input.lasso | ||
|
||
<!DOCTYPE html> | ||
html lang="en" | ||
head | ||
meta charset="UTF-8" | ||
title -- Marko Test | ||
lasso-head | ||
body | ||
|
||
div id="test" | ||
div id="mocha" | ||
div id="testsTarget" | ||
|
||
<list-items options=[ | ||
'apples', | ||
'bananas', | ||
'cherries', | ||
'dates' | ||
]/> | ||
|
||
lasso-body | ||
|
||
init-components immediate | ||
|
||
lasso-slot name="mocha-run" | ||
|
||
browser-refresh |
49 changes: 49 additions & 0 deletions
49
test/autotests/components-pages/repeated-list-items-unkeyed/tests.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
var path = require('path'); | ||
var expect = require('chai').expect; | ||
|
||
describe(path.basename(__dirname), function() { | ||
it('should update correctly', function() { | ||
var listItemsComponent = window.listItemsComponent; | ||
expect(listItemsComponent.getEl('root').querySelectorAll('li').length).to.equal(4); | ||
expect(listItemsComponent.getEl('root').querySelectorAll('a').length).to.equal(4); | ||
expect(listItemsComponent.getEl('root').querySelectorAll('a')[0].innerHTML).to.equal('apples'); | ||
expect(listItemsComponent.getEl('root').querySelectorAll('a')[1].innerHTML).to.equal('bananas'); | ||
expect(listItemsComponent.getEl('root').querySelectorAll('a')[2].innerHTML).to.equal('cherries'); | ||
expect(listItemsComponent.getEl('root').querySelectorAll('a')[3].innerHTML).to.equal('dates'); | ||
|
||
listItemsComponent.input = { | ||
options: [ | ||
'apples', | ||
'bananas' | ||
] | ||
}; | ||
listItemsComponent.update(); | ||
|
||
expect(listItemsComponent.getEl('root').querySelectorAll('li').length).to.equal(2); | ||
expect(listItemsComponent.getEl('root').querySelectorAll('a').length).to.equal(2); | ||
expect(listItemsComponent.getEl('root').querySelectorAll('a')[0].innerHTML).to.equal('apples'); | ||
expect(listItemsComponent.getEl('root').querySelectorAll('a')[1].innerHTML).to.equal('bananas'); | ||
|
||
listItemsComponent.input = { | ||
options: [] | ||
}; | ||
listItemsComponent.update(); | ||
|
||
expect(listItemsComponent.getEl('root').querySelectorAll('li').length).to.equal(0); | ||
expect(listItemsComponent.getEl('root').querySelectorAll('a').length).to.equal(0); | ||
|
||
|
||
listItemsComponent.input = { | ||
options: [ | ||
'apples', | ||
'bananas' | ||
] | ||
}; | ||
listItemsComponent.update(); | ||
|
||
expect(listItemsComponent.getEl('root').querySelectorAll('li').length).to.equal(2); | ||
expect(listItemsComponent.getEl('root').querySelectorAll('a').length).to.equal(2); | ||
expect(listItemsComponent.getEl('root').querySelectorAll('a')[0].innerHTML).to.equal('apples'); | ||
expect(listItemsComponent.getEl('root').querySelectorAll('a')[1].innerHTML).to.equal('bananas'); | ||
}); | ||
}); |