Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(58)

Side by Side Diff: pkg/shadow_dom/lib/src/platform/patches-shadowdom-polyfill.js

Issue 26391003: fix ShadowDOM on browsers with non-native template (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « pkg/shadow_dom/lib/shadow_dom.min.js ('k') | samples/samples.status » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 17 matching lines...) Expand all
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 (window.MutationRecord && (obj instanceof MutationRecord))
34 return 'MutationRecord'; 34 return 'MutationRecord';
35 if (window.MutationObserver && (obj instanceof MutationObserver)) 35 if (window.MutationObserver && (obj instanceof MutationObserver))
36 return 'MutationObserver'; 36 return 'MutationObserver';
37 37
38 // TODO(jmesserly): this prevents incorrect interaction between ShadowDOM
39 // and dart:html's <template> polyfill. Essentially, ShadowDOM is
40 // polyfilling native template, but our Dart polyfill fails to detect this
41 // because the unwrapped node is an HTMLUnknownElement, leading it to
42 // think the node has no content.
43 if (obj instanceof HTMLTemplateElement) return 'HTMLTemplateElement';
44
38 var unwrapped = unwrapIfNeeded(obj); 45 var unwrapped = unwrapIfNeeded(obj);
39 if (obj !== unwrapped) { 46 if (obj !== unwrapped) {
40 // Fix up class names for Firefox. 47 // Fix up class names for Firefox.
41 // For some of them (like HTMLFormElement and HTMLInputElement), 48 // For some of them (like HTMLFormElement and HTMLInputElement),
42 // the "constructor" property of the unwrapped nodes points at the 49 // the "constructor" property of the unwrapped nodes points at the
43 // same constructor as the wrapper. 50 // same constructor as the wrapper.
44 var ctor = obj.constructor 51 var ctor = obj.constructor
45 if (ctor === unwrapped.constructor) { 52 if (ctor === unwrapped.constructor) {
46 var name = ctor._ShadowDOMPolyfill$cacheTag_; 53 var name = ctor._ShadowDOMPolyfill$cacheTag_;
47 if (!name) { 54 if (!name) {
48 name = Object.prototype.toString.call(unwrapped); 55 name = Object.prototype.toString.call(unwrapped);
49 name = name.substring(8, name.length - 1); 56 name = name.substring(8, name.length - 1);
50 ctor._ShadowDOMPolyfill$cacheTag_ = name; 57 ctor._ShadowDOMPolyfill$cacheTag_ = name;
51 } 58 }
52 return name; 59 return name;
53 } 60 }
54 61
55 obj = unwrapped; 62 obj = unwrapped;
56 } 63 }
57 return originalGetTag(obj); 64 return originalGetTag(obj);
58 } 65 }
59 66
60 return getTag; 67 return getTag;
61 }; 68 };
62 })(); 69 })();
OLDNEW
« no previous file with comments | « pkg/shadow_dom/lib/shadow_dom.min.js ('k') | samples/samples.status » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698