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

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

Issue 23548014: update shadowdom polyfill to latest (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: updated README, add build.sh Created 7 years, 3 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') | pkg/shadow_dom/tool/README.md » ('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
11 Object.defineProperties(HTMLElement.prototype, { 11 Object.defineProperties(HTMLElement.prototype, {
12 //TODO(sjmiles): review accessor alias with Arv 12 //TODO(sjmiles): review accessor alias with Arv
13 webkitShadowRoot: { 13 webkitShadowRoot: {
14 get: function() { 14 get: function() {
15 return this.shadowRoot; 15 return this.shadowRoot;
16 } 16 }
17 } 17 }
18 }); 18 });
19 19
20 //TODO(sjmiles): review method alias with Arv 20 //TODO(sjmiles): review method alias with Arv
21 HTMLElement.prototype.webkitCreateShadowRoot = 21 HTMLElement.prototype.webkitCreateShadowRoot =
22 HTMLElement.prototype.createShadowRoot; 22 HTMLElement.prototype.createShadowRoot;
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 isWrapper = ShadowDOMPolyfill.isWrapper; 28 var unwrapIfNeeded = ShadowDOMPolyfill.unwrapIfNeeded;
29 var unwrap = ShadowDOMPolyfill.unwrap;
30 function getTag(obj) { 29 function getTag(obj) {
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 (obj instanceof MutationRecord) return 'MutationRecord';
34 if (obj instanceof MutationObserver) return 'MutationObserver'; 34 if (obj instanceof MutationObserver) return 'MutationObserver';
35 35
36 if (isWrapper(obj)) { 36 var unwrapped = unwrapIfNeeded(obj);
37 obj = unwrap(obj); 37 if (obj !== unwrapped) {
38 38 // Fix up class names for Firefox.
39 // Fix up class names for Firefox. For some of them like 39 // For some of them (like HTMLFormElement and HTMLInputElement),
40 // HTMLFormElement and HTMLInputElement, the "constructor" property of 40 // the "constructor" property of the unwrapped nodes points at the
41 // the unwrapped nodes points at the wrapper for some reason. 41 // wrapper.
42 // TODO(jmesserly): figure out why this is happening. 42 // Note: it is safe to check for the GeneratedWrapper string because
43 // we know it is some kind of Shadow DOM wrapper object.
Siggi Cherem (dart-lang) 2013/09/08 18:44:23 I thought this is safe in debug mode, but that in
43 var ctor = obj.constructor; 44 var ctor = obj.constructor;
44 if (ctor && ctor._ShadowDOMPolyfill$isGeneratedWrapper) { 45 if (ctor && ctor.name == 'GeneratedWrapper') {
45 var name = ctor._ShadowDOMPolyfill$cacheTag_; 46 var name = ctor._ShadowDOMPolyfill$cacheTag_;
46 if (!name) { 47 if (!name) {
47 name = Object.prototype.toString.call(obj); 48 name = Object.prototype.toString.call(unwrapped);
48 name = name.substring(8, name.length - 1); 49 name = name.substring(8, name.length - 1);
49 ctor._ShadowDOMPolyfill$cacheTag_ = name; 50 ctor._ShadowDOMPolyfill$cacheTag_ = name;
50 } 51 }
51 return name; 52 return name;
52 } 53 }
54
55 obj = unwrapped;
53 } 56 }
54 return originalGetTag(obj); 57 return originalGetTag(obj);
55 } 58 }
56 59
57 return getTag; 60 return getTag;
58 }; 61 };
59 })(); 62 })();
OLDNEW
« no previous file with comments | « pkg/shadow_dom/lib/shadow_dom.min.js ('k') | pkg/shadow_dom/tool/README.md » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698