| OLD | NEW |
| 1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 /** | 5 /** |
| 6 * Polyfill script for custom elements. To use this script, your app must | 6 * Polyfill script for custom elements. To use this script, your app must |
| 7 * create a CustomElementsManager with the appropriate lookup function before | 7 * create a CustomElementsManager with the appropriate lookup function before |
| 8 * doing any DOM queries or modifications. | 8 * doing any DOM queries or modifications. |
| 9 * Currently, all custom elements must be registered with the polyfill. To | 9 * Currently, all custom elements must be registered with the polyfill. To |
| 10 * register custom elements, provide the appropriate lookup function to your | 10 * register custom elements, provide the appropriate lookup function to your |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 67 // arbitrary Dart objects directly on DOM objects rather than this map. | 67 // arbitrary Dart objects directly on DOM objects rather than this map. |
| 68 /** Maps DOM elements to the user-defiend corresponding dart objects. */ | 68 /** Maps DOM elements to the user-defiend corresponding dart objects. */ |
| 69 ListMap<Element, WebComponent> _customElements; | 69 ListMap<Element, WebComponent> _customElements; |
| 70 | 70 |
| 71 RegistryLookupFunction _lookup; | 71 RegistryLookupFunction _lookup; |
| 72 | 72 |
| 73 MutationObserver _insertionObserver; | 73 MutationObserver _insertionObserver; |
| 74 | 74 |
| 75 CustomElementsManager._internal(this._lookup) { | 75 CustomElementsManager._internal(this._lookup) { |
| 76 // TODO(samhop): check for ShadowDOM support | 76 // TODO(samhop): check for ShadowDOM support |
| 77 _customDeclarations = <_CustomDeclaration>{}; | 77 _customDeclarations = <String, _CustomDeclaration>{}; |
| 78 // We use a ListMap because DOM objects aren't hashable right now. | 78 // We use a ListMap because DOM objects aren't hashable right now. |
| 79 // TODO(samhop): DOM objects (and everything else) should be hashable | 79 // TODO(samhop): DOM objects (and everything else) should be hashable |
| 80 _customElements = new ListMap<Element, WebComponent>(); | 80 _customElements = new ListMap<Element, WebComponent>(); |
| 81 initializeInsertedRemovedCallbacks(document); | 81 initializeInsertedRemovedCallbacks(document); |
| 82 } | 82 } |
| 83 | 83 |
| 84 /** | 84 /** |
| 85 * Locate all external component files, load each of them, and expand | 85 * Locate all external component files, load each of them, and expand |
| 86 * declarations. | 86 * declarations. |
| 87 */ | 87 */ |
| (...skipping 250 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 338 } | 338 } |
| 339 }); | 339 }); |
| 340 attributeObserver.observe(e, attributes: true, attributeOldValue: true); | 340 attributeObserver.observe(e, attributes: true, attributeOldValue: true); |
| 341 | 341 |
| 342 // Listen for all insertions and deletions on the DOM so that we can | 342 // Listen for all insertions and deletions on the DOM so that we can |
| 343 // catch custom elements being inserted and call the appropriate callbacks. | 343 // catch custom elements being inserted and call the appropriate callbacks. |
| 344 manager.initializeInsertedRemovedCallbacks(shadowRoot); | 344 manager.initializeInsertedRemovedCallbacks(shadowRoot); |
| 345 return newCustomElement; | 345 return newCustomElement; |
| 346 } | 346 } |
| 347 } | 347 } |
| OLD | NEW |