| 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 (obj instanceof MutationRecord) return 'MutationRecord'; | 33 if (window.MutationRecord && (obj instanceof MutationRecord)) |
| 34 if (obj instanceof MutationObserver) return 'MutationObserver'; | 34 return 'MutationRecord'; |
| 35 if (window.MutationObserver && (obj instanceof MutationObserver)) |
| 36 return 'MutationObserver'; |
| 35 | 37 |
| 36 var unwrapped = unwrapIfNeeded(obj); | 38 var unwrapped = unwrapIfNeeded(obj); |
| 37 if (obj !== unwrapped) { | 39 if (obj !== unwrapped) { |
| 38 // Fix up class names for Firefox. | 40 // Fix up class names for Firefox. |
| 39 // For some of them (like HTMLFormElement and HTMLInputElement), | 41 // For some of them (like HTMLFormElement and HTMLInputElement), |
| 40 // the "constructor" property of the unwrapped nodes points at the | 42 // the "constructor" property of the unwrapped nodes points at the |
| 41 // same constructor as the wrapper. | 43 // same constructor as the wrapper. |
| 42 var ctor = obj.constructor | 44 var ctor = obj.constructor |
| 43 if (ctor === unwrapped.constructor) { | 45 if (ctor === unwrapped.constructor) { |
| 44 var name = ctor._ShadowDOMPolyfill$cacheTag_; | 46 var name = ctor._ShadowDOMPolyfill$cacheTag_; |
| 45 if (!name) { | 47 if (!name) { |
| 46 name = Object.prototype.toString.call(unwrapped); | 48 name = Object.prototype.toString.call(unwrapped); |
| 47 name = name.substring(8, name.length - 1); | 49 name = name.substring(8, name.length - 1); |
| 48 ctor._ShadowDOMPolyfill$cacheTag_ = name; | 50 ctor._ShadowDOMPolyfill$cacheTag_ = name; |
| 49 } | 51 } |
| 50 return name; | 52 return name; |
| 51 } | 53 } |
| 52 | 54 |
| 53 obj = unwrapped; | 55 obj = unwrapped; |
| 54 } | 56 } |
| 55 return originalGetTag(obj); | 57 return originalGetTag(obj); |
| 56 } | 58 } |
| 57 | 59 |
| 58 return getTag; | 60 return getTag; |
| 59 }; | 61 }; |
| 60 })(); | 62 })(); |
| OLD | NEW |