| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2013 The Polymer Authors. All rights reserved. | 2 * Copyright 2013 The Polymer Authors. All rights reserved. |
| 3 * Use of this source code is governed by a BSD-style | 3 * Use of this source code is governed by a BSD-style |
| 4 * license that can be found in the LICENSE file. | 4 * license that can be found in the LICENSE file. |
| 5 */ | 5 */ |
| 6 (function() { | 6 (function() { |
| 7 var ShadowDOMPolyfill = window.ShadowDOMPolyfill; | 7 var ShadowDOMPolyfill = window.ShadowDOMPolyfill; |
| 8 var wrap = ShadowDOMPolyfill.wrap; | 8 var wrap = ShadowDOMPolyfill.wrap; |
| 9 | 9 |
| 10 // patch in prefixed name | 10 // patch in prefixed name |
| (...skipping 12 matching lines...) Expand all Loading... |
| 23 | 23 |
| 24 // TODO(jmesserly): we need to wrap document somehow (a dart:html hook?) | 24 // TODO(jmesserly): we need to wrap document somehow (a dart:html hook?) |
| 25 window.dartExperimentalFixupGetTag = function(originalGetTag) { | 25 window.dartExperimentalFixupGetTag = function(originalGetTag) { |
| 26 var NodeList = ShadowDOMPolyfill.wrappers.NodeList; | 26 var NodeList = ShadowDOMPolyfill.wrappers.NodeList; |
| 27 var ShadowRoot = ShadowDOMPolyfill.wrappers.ShadowRoot; | 27 var ShadowRoot = ShadowDOMPolyfill.wrappers.ShadowRoot; |
| 28 var unwrapIfNeeded = ShadowDOMPolyfill.unwrapIfNeeded; | 28 var unwrapIfNeeded = ShadowDOMPolyfill.unwrapIfNeeded; |
| 29 function getTag(obj) { | 29 function getTag(obj) { |
| 30 // TODO(jmesserly): do we still need these? | 30 // TODO(jmesserly): do we still need these? |
| 31 if (obj instanceof NodeList) return 'NodeList'; | 31 if (obj instanceof NodeList) return 'NodeList'; |
| 32 if (obj instanceof ShadowRoot) return 'ShadowRoot'; | 32 if (obj instanceof ShadowRoot) return 'ShadowRoot'; |
| 33 if (window.MutationRecord && (obj instanceof MutationRecord)) | 33 if (obj instanceof MutationRecord) return 'MutationRecord'; |
| 34 return 'MutationRecord'; | 34 if (obj instanceof MutationObserver) return 'MutationObserver'; |
| 35 if (window.MutationObserver && (obj instanceof MutationObserver)) | |
| 36 return 'MutationObserver'; | |
| 37 | 35 |
| 38 var unwrapped = unwrapIfNeeded(obj); | 36 var unwrapped = unwrapIfNeeded(obj); |
| 39 if (obj !== unwrapped) { | 37 if (obj !== unwrapped) { |
| 40 // Fix up class names for Firefox. | 38 // Fix up class names for Firefox. |
| 41 // For some of them (like HTMLFormElement and HTMLInputElement), | 39 // For some of them (like HTMLFormElement and HTMLInputElement), |
| 42 // the "constructor" property of the unwrapped nodes points at the | 40 // the "constructor" property of the unwrapped nodes points at the |
| 43 // same constructor as the wrapper. | 41 // same constructor as the wrapper. |
| 44 var ctor = obj.constructor | 42 var ctor = obj.constructor |
| 45 if (ctor === unwrapped.constructor) { | 43 if (ctor === unwrapped.constructor) { |
| 46 var name = ctor._ShadowDOMPolyfill$cacheTag_; | 44 var name = ctor._ShadowDOMPolyfill$cacheTag_; |
| 47 if (!name) { | 45 if (!name) { |
| 48 name = Object.prototype.toString.call(unwrapped); | 46 name = Object.prototype.toString.call(unwrapped); |
| 49 name = name.substring(8, name.length - 1); | 47 name = name.substring(8, name.length - 1); |
| 50 ctor._ShadowDOMPolyfill$cacheTag_ = name; | 48 ctor._ShadowDOMPolyfill$cacheTag_ = name; |
| 51 } | 49 } |
| 52 return name; | 50 return name; |
| 53 } | 51 } |
| 54 | 52 |
| 55 obj = unwrapped; | 53 obj = unwrapped; |
| 56 } | 54 } |
| 57 return originalGetTag(obj); | 55 return originalGetTag(obj); |
| 58 } | 56 } |
| 59 | 57 |
| 60 return getTag; | 58 return getTag; |
| 61 }; | 59 }; |
| 62 })(); | 60 })(); |
| OLD | NEW |