Skip to content

Commit c3fbd10

Browse files
author
Steven Orvell
committed
remove unused code; minor changes based on review.
1 parent e3753db commit c3fbd10

3 files changed

Lines changed: 13 additions & 67 deletions

File tree

‎src/lib/experimental/patch-dom.html‎

Lines changed: 13 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@
123123

124124
methods: ['appendChild', 'insertBefore', 'removeChild', 'replaceChild',
125125
'querySelector', 'querySelectorAll', 'getDestinationInsertionPoints',
126-
'cloneNode', /*'importNode',*/ 'setAttribute', 'removeAttribute'],
126+
'cloneNode', 'setAttribute', 'removeAttribute'],
127127
// <content>: getDistributedNodes
128128

129129
accessors: ['parentNode', 'childNodes',
@@ -192,10 +192,6 @@
192192
}
193193
var info = {
194194
get: function() {
195-
//log && console.log(this, name);
196-
if (window.nug) {
197-
debugger;
198-
}
199195
return dom(this)[name];
200196
},
201197
configurable: true
@@ -243,6 +239,8 @@
243239

244240
Polymer.DomApi.patchImpl = patchImpl;
245241

242+
// NOTE: patch logical implementations here so we can use
243+
// composed getters
246244
Polymer.TreeApi.Logical.saveChildNodes = function(node) {
247245
if (!this.hasChildNodes(node)) {
248246
node.__firstChild = node.firstChild;
@@ -277,10 +275,6 @@
277275

278276
Polymer.TreeApi.Composed = {
279277

280-
281-
ensureParentNodes: function(parent, children) {
282-
},
283-
284278
hasParentNode: function(node) {
285279
return Boolean(node.__composedParent !== undefined);
286280
},
@@ -290,10 +284,7 @@
290284
},
291285

292286
getChildNodes: function(node) {
293-
// return node.__composedChildNodes ||
294-
// (!node.__patched && TreeApi.arrayCopy(node.childNodes));
295-
return (node.__composedChildNodes &&
296-
TreeApi.arrayCopy(node.__composedChildNodes)) ||
287+
return node.__composedChildNodes ||
297288
(!node.__patched && TreeApi.arrayCopy(node.childNodes));
298289
},
299290

@@ -326,25 +317,25 @@
326317
getNextSibling: function(node) {
327318
// TODO(sorvell): linked list
328319
var parent = this.getParentNode(node);
329-
//if (parent.__patched) {
320+
if (parent.__patched) {
330321
var c$ = this.getChildNodes(parent);
331322
var i = c$.indexOf(node);
332323
return c$[i+1];
333-
//} else if (!node.__patched) {
334-
// return node.nextSibling;
335-
//}
324+
} else if (!node.__patched) {
325+
return node.nextSibling;
326+
}
336327
},
337328

338329
getPreviousSibling: function(node) {
339330
// TODO(sorvell): linked list
340331
var parent = this.getParentNode(node);
341-
//if (parent.__patched) {
332+
if (parent.__patched) {
342333
var c$ = this.getChildNodes(parent);
343334
var i = c$.indexOf(node);
344335
return c$[i-1];
345-
//} else if (!node.__patched) {
346-
// return node.previousSibling;
347-
//}
336+
} else if (!node.__patched) {
337+
return node.previousSibling;
338+
}
348339
},
349340

350341
// composed tracking needs to reset composed children here in case
@@ -407,8 +398,8 @@
407398
}
408399
this._removeChild(parentNode, node);
409400
if (currentParent === parentNode) {
401+
// TODO(sorvell); abort if the composedParent is not expected...
410402
if (!node.__patched && node.parentNode !== node.__composedParent) {
411-
//console.warn('composedParent wrong for', node);
412403
return;
413404
}
414405
return nativeRemoveChild.call(parentNode, node);
@@ -445,13 +436,6 @@
445436

446437
};
447438

448-
// TODO(sorvell): only necessary if we allow document.importNode to be patched.
449-
// var nativeImportNode = document.importNode;
450-
// Polymer.Base.instanceTemplate = function(template) {
451-
// return nativeImportNode.call(document,
452-
// template._content || template.content, true);
453-
// }
454-
455439
// patch important nodes
456440
if (window.document) {
457441
Polymer.dom(document);

‎src/mini/shady.html‎

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -353,8 +353,6 @@
353353
composed.splice(j, 0, n);
354354
}
355355
}
356-
// ensure composed parent is set
357-
TreeApi.Composed.ensureParentNodes(container, children);
358356
},
359357

360358
_matchesContentSelect: function(node, contentElement) {

‎test/smoke/patch/patch-dom.html‎

Lines changed: 0 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -247,8 +247,6 @@
247247
s.id = 'light';
248248
s.textContent = 'Light';
249249
rere.appendChild(s);
250-
// TODO(sorvell); patch
251-
Polymer.dom(s);
252250
assert.equal(rere.querySelector('#light'), s);
253251
assert.equal(s.parentNode, rere);
254252
Polymer.dom.flush();
@@ -298,35 +296,6 @@
298296
assert.notOk(projected);
299297
});
300298

301-
test('Polymer.dom event', function() {
302-
var test = document.querySelector('x-test');
303-
var rere = test.root.querySelector('x-rereproject');
304-
var re = rere.root.querySelector('x-reproject');
305-
var p = re.root.querySelector('x-project');
306-
var eventHandled = 0;
307-
test.addEventListener('test-event', function(e) {
308-
eventHandled++;
309-
assert.equal(Polymer.dom(e).rootTarget, p);
310-
assert.equal(Polymer.dom(e).localTarget, test);
311-
var path = Polymer.dom(e).path;
312-
// path includes window only on more recent Shadow DOM implementations
313-
// account for that here.
314-
assert.ok(path.length >= 10);
315-
assert.equal(path[0], p);
316-
assert.equal(path[2], re);
317-
assert.equal(path[4], rere);
318-
assert.equal(path[6], test);
319-
});
320-
321-
rere.addEventListener('test-event', function(e) {
322-
eventHandled++;
323-
assert.equal(Polymer.dom(e).localTarget, rere);
324-
});
325-
326-
p.fire('test-event');
327-
assert.equal(eventHandled, 2);
328-
});
329-
330299
test('Polymer.dom.childNodes is an array', function() {
331300
assert.isTrue(Array.isArray(Polymer.dom(document.body).childNodes));
332301
});
@@ -395,17 +364,12 @@
395364
testNoAttr();
396365
// set / unset `test` attr and see if it distributes properly
397366
child.setAttribute('test', '');
398-
//d.distributeContent();
399367
Polymer.dom.flush();
400368
testWithAttr();
401-
//
402369
child.removeAttribute('test');
403-
//d.distributeContent();
404370
Polymer.dom.flush();
405371
testNoAttr();
406-
//
407372
child.setAttribute('test', '');
408-
//d.distributeContent();
409373
Polymer.dom.flush();
410374
testWithAttr();
411375
});

0 commit comments

Comments
 (0)