| OLD | NEW |
| 1 if ((!HTMLElement.prototype.createShadowRoot && | 1 if ((!HTMLElement.prototype.createShadowRoot && |
| 2 !HTMLElement.prototype.webkitCreateShadowRoot) || | 2 !HTMLElement.prototype.webkitCreateShadowRoot) || |
| 3 window.__forceShadowDomPolyfill) { | 3 window.__forceShadowDomPolyfill) { |
| 4 | 4 |
| 5 /* | 5 /* |
| 6 * Copyright 2013 The Polymer Authors. All rights reserved. | 6 * Copyright 2013 The Polymer Authors. All rights reserved. |
| 7 * Use of this source code is governed by a BSD-style | 7 * Use of this source code is governed by a BSD-style |
| 8 * license that can be found in the LICENSE file. | 8 * license that can be found in the LICENSE file. |
| 9 */ | 9 */ |
| 10 (function() { | 10 (function() { |
| (...skipping 214 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 225 return GeneratedWrapper; | 225 return GeneratedWrapper; |
| 226 } | 226 } |
| 227 | 227 |
| 228 function createWrapperConstructor(superWrapperConstructor) { | 228 function createWrapperConstructor(superWrapperConstructor) { |
| 229 function GeneratedWrapper(node) { | 229 function GeneratedWrapper(node) { |
| 230 superWrapperConstructor.call(this, node); | 230 superWrapperConstructor.call(this, node); |
| 231 } | 231 } |
| 232 GeneratedWrapper.prototype = | 232 GeneratedWrapper.prototype = |
| 233 Object.create(superWrapperConstructor.prototype); | 233 Object.create(superWrapperConstructor.prototype); |
| 234 GeneratedWrapper.prototype.constructor = GeneratedWrapper; | 234 GeneratedWrapper.prototype.constructor = GeneratedWrapper; |
| 235 // We add this property to work around a Firefox bug where HTMLFormElement |
| 236 // and HTMLInputElements sometimes have their constructor incorrectly |
| 237 // attached to GeneratedWrapper. See lib/patches-shadowdom-polyfill.js |
| 238 GeneratedWrapper._ShadowDOMPolyfill$isGeneratedWrapper = true; |
| 235 | 239 |
| 236 return GeneratedWrapper; | 240 return GeneratedWrapper; |
| 237 } | 241 } |
| 238 | 242 |
| 239 var OriginalDOMImplementation = DOMImplementation; | 243 var OriginalDOMImplementation = DOMImplementation; |
| 240 var OriginalEvent = Event; | 244 var OriginalEvent = Event; |
| 241 var OriginalNode = Node; | 245 var OriginalNode = Node; |
| 242 var OriginalWindow = Window; | 246 var OriginalWindow = Window; |
| 243 | 247 |
| 244 function isWrapper(object) { | 248 function isWrapper(object) { |
| (...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 360 scope.registerObject = registerObject; | 364 scope.registerObject = registerObject; |
| 361 scope.registerWrapper = register; | 365 scope.registerWrapper = register; |
| 362 scope.rewrap = rewrap; | 366 scope.rewrap = rewrap; |
| 363 scope.unwrap = unwrap; | 367 scope.unwrap = unwrap; |
| 364 scope.unwrapIfNeeded = unwrapIfNeeded; | 368 scope.unwrapIfNeeded = unwrapIfNeeded; |
| 365 scope.wrap = wrap; | 369 scope.wrap = wrap; |
| 366 scope.wrapIfNeeded = wrapIfNeeded; | 370 scope.wrapIfNeeded = wrapIfNeeded; |
| 367 scope.wrappers = wrappers; | 371 scope.wrappers = wrappers; |
| 368 | 372 |
| 369 })(this.ShadowDOMPolyfill); | 373 })(this.ShadowDOMPolyfill); |
| 374 |
| 370 // Copyright 2013 The Polymer Authors. All rights reserved. | 375 // Copyright 2013 The Polymer Authors. All rights reserved. |
| 371 // Use of this source code is goverened by a BSD-style | 376 // Use of this source code is goverened by a BSD-style |
| 372 // license that can be found in the LICENSE file. | 377 // license that can be found in the LICENSE file. |
| 373 | 378 |
| 374 (function(scope) { | 379 (function(scope) { |
| 375 'use strict'; | 380 'use strict'; |
| 376 | 381 |
| 377 var forwardMethodsToWrapper = scope.forwardMethodsToWrapper; | 382 var forwardMethodsToWrapper = scope.forwardMethodsToWrapper; |
| 378 var mixin = scope.mixin; | 383 var mixin = scope.mixin; |
| 379 var registerWrapper = scope.registerWrapper; | 384 var registerWrapper = scope.registerWrapper; |
| (...skipping 2766 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3146 get: function() { | 3151 get: function() { |
| 3147 return this.shadowRoot; | 3152 return this.shadowRoot; |
| 3148 } | 3153 } |
| 3149 } | 3154 } |
| 3150 }); | 3155 }); |
| 3151 | 3156 |
| 3152 //TODO(sjmiles): review method alias with Arv | 3157 //TODO(sjmiles): review method alias with Arv |
| 3153 HTMLElement.prototype.webkitCreateShadowRoot = | 3158 HTMLElement.prototype.webkitCreateShadowRoot = |
| 3154 HTMLElement.prototype.createShadowRoot; | 3159 HTMLElement.prototype.createShadowRoot; |
| 3155 | 3160 |
| 3156 // TODO(jmesserly): figure out what to do about these Dart-specific patches | |
| 3157 // Right now it depends on some dart2js impl details to patch getTypeNameOf | |
| 3158 // TODO(jmesserly): we need to wrap document somehow (a dart:html hook?) | 3161 // TODO(jmesserly): we need to wrap document somehow (a dart:html hook?) |
| 3159 window.dartMainRunner = function(main) { | 3162 window.dartExperimentalFixupGetTag = function(originalGetTag) { |
| 3160 var NodeList = ShadowDOMPolyfill.wrappers.NodeList; | 3163 var NodeList = ShadowDOMPolyfill.wrappers.NodeList; |
| 3161 var ShadowRoot = ShadowDOMPolyfill.wrappers.ShadowRoot; | 3164 var ShadowRoot = ShadowDOMPolyfill.wrappers.ShadowRoot; |
| 3162 var isWrapper = ShadowDOMPolyfill.isWrapper; | 3165 var isWrapper = ShadowDOMPolyfill.isWrapper; |
| 3163 var unwrap = ShadowDOMPolyfill.unwrap; | 3166 var unwrap = ShadowDOMPolyfill.unwrap; |
| 3164 var innerTypeNameOf = window.$.getFunctionForTypeNameOf(); | 3167 function getTag(obj) { |
| 3168 if (obj instanceof NodeList) return 'NodeList'; |
| 3169 if (obj instanceof ShadowRoot) return 'ShadowRoot'; |
| 3170 if (obj instanceof MutationRecord) return 'MutationRecord'; |
| 3171 if (obj instanceof MutationObserver) return 'MutationObserver'; |
| 3165 | 3172 |
| 3166 function typeNameOfShadowDOM(obj) { | 3173 if (isWrapper(obj)) { |
| 3167 var result; | 3174 obj = unwrap(obj); |
| 3168 if (obj instanceof NodeList) { | |
| 3169 result = 'NodeList'; | |
| 3170 } else if (obj instanceof ShadowRoot) { | |
| 3171 result = 'ShadowRoot'; | |
| 3172 } else if (obj instanceof MutationRecord) { | |
| 3173 result = 'MutationRecord'; | |
| 3174 } else if (obj instanceof MutationObserver) { | |
| 3175 result = 'MutationObserver'; | |
| 3176 } else { | |
| 3177 if (isWrapper(obj)) { | |
| 3178 obj = unwrap(obj); | |
| 3179 | 3175 |
| 3180 // Fix up class names for Firefox. For some of them like | 3176 // Fix up class names for Firefox. For some of them like |
| 3181 // HTMLFormElement and HTMLInputElement, the "constructor" property of | 3177 // HTMLFormElement and HTMLInputElement, the "constructor" property of |
| 3182 // the unwrapped nodes points at the wrapper for some reason. | 3178 // the unwrapped nodes points at the wrapper for some reason. |
| 3183 // TODO(jmesserly): figure out why this is happening. | 3179 // TODO(jmesserly): figure out why this is happening. |
| 3184 var ctor = obj.constructor; | 3180 var ctor = obj.constructor; |
| 3185 if (ctor && !ctor.builtin$cls && ctor.name == 'GeneratedWrapper') { | 3181 if (ctor && ctor._ShadowDOMPolyfill$isGeneratedWrapper) { |
| 3186 var name = Object.prototype.toString.call(obj); | 3182 var name = ctor._ShadowDOMPolyfill$cacheTag_; |
| 3183 if (!name) { |
| 3184 name = Object.prototype.toString.call(obj); |
| 3187 name = name.substring(8, name.length - 1); | 3185 name = name.substring(8, name.length - 1); |
| 3188 ctor.builtin$cls = name; | 3186 ctor._ShadowDOMPolyfill$cacheTag_ = name; |
| 3189 } | 3187 } |
| 3188 return name; |
| 3190 } | 3189 } |
| 3191 | |
| 3192 result = innerTypeNameOf.call$1(obj); | |
| 3193 } | 3190 } |
| 3194 | 3191 return originalGetTag(obj); |
| 3195 return result; | |
| 3196 } | 3192 } |
| 3197 | 3193 |
| 3198 function constructorNameShadowDOM(object) { | 3194 return getTag; |
| 3199 var $constructor, $name, string; | |
| 3200 if (object == null) | |
| 3201 return "Null"; | |
| 3202 $constructor = object.constructor; | |
| 3203 if (typeof $constructor === "function") { | |
| 3204 $name = $constructor.builtin$cls; | |
| 3205 if ($name != null) | |
| 3206 return $name; | |
| 3207 } | |
| 3208 | |
| 3209 } | |
| 3210 | |
| 3211 window.$.constructorNameFallback = constructorNameShadowDOM; | |
| 3212 window.$._getTypeNameOf = { call$1: typeNameOfShadowDOM }; | |
| 3213 window.Isolate.$isolateProperties._getTypeNameOf = window.$._getTypeNameOf; | |
| 3214 | |
| 3215 // Invoke the real main | |
| 3216 main(); | |
| 3217 }; | 3195 }; |
| 3218 | |
| 3219 })(); | 3196 })(); |
| 3220 | 3197 |
| 3221 } | 3198 } |
| OLD | NEW |