From ab431ed6a2e61df803e67b087fa26c785e8d3274 Mon Sep 17 00:00:00 2001 From: Steven Orvell Date: Wed, 22 Jun 2016 09:20:53 -0700 Subject: [PATCH] Fixes #3730 and inspired by (https://github.com/Polymer/polymer/pull/3585) --- src/lib/dom-tree-api.html | 2 +- test/unit/polymer-dom.js | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/src/lib/dom-tree-api.html b/src/lib/dom-tree-api.html index ccf0dea031..37fa72cb26 100644 --- a/src/lib/dom-tree-api.html +++ b/src/lib/dom-tree-api.html @@ -215,7 +215,7 @@ node.__dom.previousSibling.__dom.nextSibling = node; } // update node <-> ref_node - node.__dom.nextSibling = ref_node; + node.__dom.nextSibling = ref_node || null; if (node.__dom.nextSibling) { node.__dom.nextSibling.__dom.previousSibling = node; } diff --git a/test/unit/polymer-dom.js b/test/unit/polymer-dom.js index 02af167e9f..76bc284232 100644 --- a/test/unit/polymer-dom.js +++ b/test/unit/polymer-dom.js @@ -704,11 +704,13 @@ suite('Polymer.dom accessors', function() { var after = document.createElement('div'); Polymer.dom(noDistribute).insertBefore(before, child); Polymer.dom(noDistribute).appendChild(after); + Polymer.dom.flush(); assert.equal(Polymer.dom(noDistribute).firstChild, before, 'firstChild incorrect'); assert.equal(Polymer.dom(noDistribute).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).previousSibling, child, 'previousSibling incorrect'); + assert.equal(Polymer.dom(after).nextSibling, null, 'nextSibling incorrect'); assert.equal(Polymer.dom(child).previousSibling, before, 'previousSibling incorrect'); }); @@ -719,11 +721,13 @@ 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).previousSibling, child, 'previousSibling incorrect'); + assert.equal(Polymer.dom(after).nextSibling, null, 'nextSibling incorrect'); assert.equal(Polymer.dom(child).previousSibling, before, 'previousSibling incorrect'); });