Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix nextSibling after appendChild #3585

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Fix nextSibling after appendChild
If ref_node is undefined instead of null, node.__dom.nextSibling is
undefined too. Because of this, Polymer.dom(node).nextSibling is the
nextSibling in the browser DOM instead of null.
  • Loading branch information
jscissr committed Apr 13, 2016
commit 4fab6bd04213fd399951003b0a759228e6783528
1 change: 1 addition & 0 deletions src/lib/dom-api-shady.html
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@
// container to container.host.
// 3. node is <content> (host of container needs distribution)
insertBefore: function(node, ref_node) {
ref_node = ref_node || null;
if (ref_node && TreeApi.Logical.getParentNode(ref_node) !== this.node) {
throw Error('The ref_node to be inserted before is not a child ' +
'of this node');
Expand Down
2 changes: 2 additions & 0 deletions test/unit/polymer-dom.js
Original file line number Diff line number Diff line change
Expand Up @@ -719,10 +719,12 @@ suite('Polymer.dom accessors', function() {
var after = document.createElement('div');
Polymer.dom(distribute).insertBefore(before, child);
Polymer.dom(distribute).appendChild(after);
Polymer.dom.flush();
assert.equal(Polymer.dom(distribute).firstChild, before, 'firstChild incorrect');
assert.equal(Polymer.dom(distribute).lastChild, after, 'lastChild incorrect');
assert.equal(Polymer.dom(before).nextSibling, child, 'nextSibling incorrect');
assert.equal(Polymer.dom(child).nextSibling, after, 'nextSibling incorrect');
assert.equal(Polymer.dom(after).nextSibling, null, 'nextSibling incorrect');
assert.equal(Polymer.dom(after).previousSibling, child, 'previousSibling incorrect');
assert.equal(Polymer.dom(child).previousSibling, before, 'previousSibling incorrect');
});
Expand Down