Skip to content

Commit

Permalink
Changes based on review.
Browse files Browse the repository at this point in the history
  • Loading branch information
Steven Orvell committed Dec 8, 2018
1 parent b8f3b79 commit 42b13d0
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 14 deletions.
9 changes: 5 additions & 4 deletions lib/elements/dom-if.js
Original file line number Diff line number Diff line change
Expand Up @@ -255,11 +255,12 @@ export class DomIf extends PolymerElement {
if (c$ && c$.length) {
// use first child parent, for case when dom-if may have been detached
let parent = wrap(c$[0]).parentNode;
// Instance children may be disconnected from parents when dom-if
// detaches if a tree was innerHTML'ed
if (parent) {
// Instance children may be disconnected from parents when dom-if
// detaches if a tree was innerHTML'ed
if (parent) {
parent = wrap(parent);
for (let i=0, n; (i<c$.length) && (n=c$[i]); i++) {
wrap(parent).removeChild(n);
parent.removeChild(n);
}
}
}
Expand Down
10 changes: 6 additions & 4 deletions lib/elements/dom-repeat.js
Original file line number Diff line number Diff line change
Expand Up @@ -324,9 +324,9 @@ export class DomRepeat extends domRepeatBase {
// only perform attachment if the element was previously detached.
if (this.__isDetached) {
this.__isDetached = false;
let parent = wrap(this).parentNode;
let wrappedParent = wrap(wrap(this).parentNode);
for (let i=0; i<this.__instances.length; i++) {
this.__attachInstance(i, parent);
this.__attachInstance(i, wrappedParent);
}
}
}
Expand Down Expand Up @@ -584,16 +584,18 @@ export class DomRepeat extends domRepeatBase {

__detachInstance(idx) {
let inst = this.__instances[idx];
const wrappedRoot = wrap(inst.root);
for (let i=0; i<inst.children.length; i++) {
let el = inst.children[i];
wrap(inst.root).appendChild(el);
wrappedRoot.appendChild(el);
}
return inst;
}

__attachInstance(idx, parent) {
let inst = this.__instances[idx];
wrap(parent).insertBefore(inst.root, this);
// Note, this is pre-wrapped as an optimization
parent.insertBefore(inst.root, this);
}

__detachAndRemoveInstance(idx) {
Expand Down
10 changes: 4 additions & 6 deletions lib/legacy/legacy-element-mixin.js
Original file line number Diff line number Diff line change
Expand Up @@ -482,9 +482,8 @@ export const LegacyElementMixin = dedupingMixin((base) => {
* @return {Element} Element found by the selector, or null if not found.
*/
$$(slctr) {
const root = /** @type {Element} */ (this.root);
const domApi = /** @type {DomApi} */(dom(root));
return domApi.querySelector(slctr);
// Note, no need to `wrap` this because root is always patched
return this.root.querySelector(slctr);
}

/**
Expand Down Expand Up @@ -607,9 +606,8 @@ export const LegacyElementMixin = dedupingMixin((base) => {
* @return {!Array<!Node>} List of distributed nodes for the `<slot>`.
*/
getContentChildNodes(slctr) {
const root = /** @type {Element} */ (this.root);
const domApi = /** @type {DomApi} */(dom(root));
let content = domApi.querySelector(slctr || 'slot');
// Note, no need to `wrap` this because root is always
let content = this.root.querySelector(slctr || 'slot');
return content ? /** @type {DomApi} */(dom(content)).getDistributedNodes() : [];
}

Expand Down

0 comments on commit 42b13d0

Please sign in to comment.