|
123 | 123 |
|
124 | 124 | methods: ['appendChild', 'insertBefore', 'removeChild', 'replaceChild', |
125 | 125 | 'querySelector', 'querySelectorAll', 'getDestinationInsertionPoints', |
126 | | - 'cloneNode', /*'importNode',*/ 'setAttribute', 'removeAttribute'], |
| 126 | + 'cloneNode', 'setAttribute', 'removeAttribute'], |
127 | 127 | // <content>: getDistributedNodes |
128 | 128 |
|
129 | 129 | accessors: ['parentNode', 'childNodes', |
|
192 | 192 | } |
193 | 193 | var info = { |
194 | 194 | get: function() { |
195 | | - //log && console.log(this, name); |
196 | | - if (window.nug) { |
197 | | - debugger; |
198 | | - } |
199 | 195 | return dom(this)[name]; |
200 | 196 | }, |
201 | 197 | configurable: true |
|
243 | 239 |
|
244 | 240 | Polymer.DomApi.patchImpl = patchImpl; |
245 | 241 |
|
| 242 | + // NOTE: patch logical implementations here so we can use |
| 243 | + // composed getters |
246 | 244 | Polymer.TreeApi.Logical.saveChildNodes = function(node) { |
247 | 245 | if (!this.hasChildNodes(node)) { |
248 | 246 | node.__firstChild = node.firstChild; |
|
277 | 275 |
|
278 | 276 | Polymer.TreeApi.Composed = { |
279 | 277 |
|
280 | | - |
281 | | - ensureParentNodes: function(parent, children) { |
282 | | - }, |
283 | | - |
284 | 278 | hasParentNode: function(node) { |
285 | 279 | return Boolean(node.__composedParent !== undefined); |
286 | 280 | }, |
|
290 | 284 | }, |
291 | 285 |
|
292 | 286 | 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 || |
297 | 288 | (!node.__patched && TreeApi.arrayCopy(node.childNodes)); |
298 | 289 | }, |
299 | 290 |
|
|
326 | 317 | getNextSibling: function(node) { |
327 | 318 | // TODO(sorvell): linked list |
328 | 319 | var parent = this.getParentNode(node); |
329 | | - //if (parent.__patched) { |
| 320 | + if (parent.__patched) { |
330 | 321 | var c$ = this.getChildNodes(parent); |
331 | 322 | var i = c$.indexOf(node); |
332 | 323 | return c$[i+1]; |
333 | | - //} else if (!node.__patched) { |
334 | | - // return node.nextSibling; |
335 | | - //} |
| 324 | + } else if (!node.__patched) { |
| 325 | + return node.nextSibling; |
| 326 | + } |
336 | 327 | }, |
337 | 328 |
|
338 | 329 | getPreviousSibling: function(node) { |
339 | 330 | // TODO(sorvell): linked list |
340 | 331 | var parent = this.getParentNode(node); |
341 | | - //if (parent.__patched) { |
| 332 | + if (parent.__patched) { |
342 | 333 | var c$ = this.getChildNodes(parent); |
343 | 334 | var i = c$.indexOf(node); |
344 | 335 | return c$[i-1]; |
345 | | - //} else if (!node.__patched) { |
346 | | - // return node.previousSibling; |
347 | | - //} |
| 336 | + } else if (!node.__patched) { |
| 337 | + return node.previousSibling; |
| 338 | + } |
348 | 339 | }, |
349 | 340 |
|
350 | 341 | // composed tracking needs to reset composed children here in case |
|
407 | 398 | } |
408 | 399 | this._removeChild(parentNode, node); |
409 | 400 | if (currentParent === parentNode) { |
| 401 | + // TODO(sorvell); abort if the composedParent is not expected... |
410 | 402 | if (!node.__patched && node.parentNode !== node.__composedParent) { |
411 | | - //console.warn('composedParent wrong for', node); |
412 | 403 | return; |
413 | 404 | } |
414 | 405 | return nativeRemoveChild.call(parentNode, node); |
|
445 | 436 |
|
446 | 437 | }; |
447 | 438 |
|
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 | | - |
455 | 439 | // patch important nodes |
456 | 440 | if (window.document) { |
457 | 441 | Polymer.dom(document); |
|
0 commit comments