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

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

Issue 22951003: Build shadow_dom package in dart/pkg (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Use ShadowDOM test file Created 7 years, 4 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
OLDNEW
(Empty)
1 /*
2 * Copyright 2013 The Polymer Authors. All rights reserved.
3 * Use of this source code is governed by a BSD-style
4 * license that can be found in the LICENSE file.
5 */
6 (function() {
7 var ShadowDOMPolyfill = window.ShadowDOMPolyfill;
8 var wrap = ShadowDOMPolyfill.wrap;
9
10 // patch in prefixed name
11 Object.defineProperties(HTMLElement.prototype, {
12 //TODO(sjmiles): review accessor alias with Arv
13 webkitShadowRoot: {
14 get: function() {
15 return this.shadowRoot;
16 }
17 }
18 });
19
20 //TODO(sjmiles): review method alias with Arv
21 HTMLElement.prototype.webkitCreateShadowRoot =
22 HTMLElement.prototype.createShadowRoot;
23
24 // TODO(jmesserly): we need to wrap document somehow (a dart:html hook?)
25 window.dartExperimentalFixupGetTag = function(originalGetTag) {
26 var NodeList = ShadowDOMPolyfill.wrappers.NodeList;
27 var ShadowRoot = ShadowDOMPolyfill.wrappers.ShadowRoot;
28 var isWrapper = ShadowDOMPolyfill.isWrapper;
29 var unwrap = ShadowDOMPolyfill.unwrap;
30 function getTag(obj) {
31 if (obj instanceof NodeList) return 'NodeList';
32 if (obj instanceof ShadowRoot) return 'ShadowRoot';
33 if (obj instanceof MutationRecord) return 'MutationRecord';
34 if (obj instanceof MutationObserver) return 'MutationObserver';
35
36 if (isWrapper(obj)) {
37 obj = unwrap(obj);
38
39 // Fix up class names for Firefox. For some of them like
40 // HTMLFormElement and HTMLInputElement, the "constructor" property of
41 // the unwrapped nodes points at the wrapper for some reason.
42 // TODO(jmesserly): figure out why this is happening.
43 var ctor = obj.constructor;
44 if (ctor && ctor._ShadowDOMPolyfill$isGeneratedWrapper) {
45 var name = ctor._ShadowDOMPolyfill$cacheTag_;
46 if (!name) {
47 name = Object.prototype.toString.call(obj);
48 name = name.substring(8, name.length - 1);
49 ctor._ShadowDOMPolyfill$cacheTag_ = name;
50 }
51 return name;
52 }
53 }
54 return originalGetTag(obj);
55 }
56
57 return getTag;
58 };
59 })();
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698