| Index: runtime/bin/vmservice/client/deployed/web/packages/shadow_dom/src/platform/patches-shadowdom-polyfill.js
|
| diff --git a/pkg/web_components/lib/dart_support.js b/runtime/bin/vmservice/client/deployed/web/packages/shadow_dom/src/platform/patches-shadowdom-polyfill.js
|
| similarity index 58%
|
| copy from pkg/web_components/lib/dart_support.js
|
| copy to runtime/bin/vmservice/client/deployed/web/packages/shadow_dom/src/platform/patches-shadowdom-polyfill.js
|
| index 44b5a38cad1912c75ad8e8b5be586d05e845aa86..a5749abba1b791461572c85ecd259b54b1461d09 100644
|
| --- a/pkg/web_components/lib/dart_support.js
|
| +++ b/runtime/bin/vmservice/client/deployed/web/packages/shadow_dom/src/platform/patches-shadowdom-polyfill.js
|
| @@ -1,18 +1,29 @@
|
| -// Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file
|
| -// for details. All rights reserved. Use of this source code is governed by a
|
| -// BSD-style license that can be found in the LICENSE file.
|
| -
|
| +/*
|
| + * Copyright 2013 The Polymer Authors. All rights reserved.
|
| + * Use of this source code is governed by a BSD-style
|
| + * license that can be found in the LICENSE file.
|
| + */
|
| (function() {
|
| var ShadowDOMPolyfill = window.ShadowDOMPolyfill;
|
| - if (!ShadowDOMPolyfill) return;
|
| + var wrap = ShadowDOMPolyfill.wrap;
|
| +
|
| + // patch in prefixed name
|
| + Object.defineProperties(HTMLElement.prototype, {
|
| + //TODO(sjmiles): review accessor alias with Arv
|
| + webkitShadowRoot: {
|
| + get: function() {
|
| + return this.shadowRoot;
|
| + }
|
| + }
|
| + });
|
|
|
| - if (navigator.userAgent.indexOf('(Dart)') !== -1) {
|
| - console.error("ShadowDOMPolyfill polyfill was loaded in Dartium. This " +
|
| - "will not work. This indicates that Dartium's Chrome version is " +
|
| - "not compatible with this version of web_components.");
|
| - }
|
| + // ShadowCSS needs this:
|
| + window.wrap = window.ShadowDOMPolyfill.wrap;
|
| + window.unwrap = window.ShadowDOMPolyfill.unwrap;
|
|
|
| - var needsConstructorFix = window.constructor === window.Window;
|
| + //TODO(sjmiles): review method alias with Arv
|
| + HTMLElement.prototype.webkitCreateShadowRoot =
|
| + HTMLElement.prototype.createShadowRoot;
|
|
|
| // TODO(jmesserly): we need to wrap document somehow (a dart:html hook?)
|
| window.dartExperimentalFixupGetTag = function(originalGetTag) {
|
| @@ -23,9 +34,9 @@
|
| // TODO(jmesserly): do we still need these?
|
| if (obj instanceof NodeList) return 'NodeList';
|
| if (obj instanceof ShadowRoot) return 'ShadowRoot';
|
| - if (MutationRecord && (obj instanceof MutationRecord))
|
| + if (window.MutationRecord && (obj instanceof MutationRecord))
|
| return 'MutationRecord';
|
| - if (MutationObserver && (obj instanceof MutationObserver))
|
| + if (window.MutationObserver && (obj instanceof MutationObserver))
|
| return 'MutationObserver';
|
|
|
| // TODO(jmesserly): this prevents incorrect interaction between ShadowDOM
|
| @@ -36,10 +47,11 @@
|
| if (obj instanceof HTMLTemplateElement) return 'HTMLTemplateElement';
|
|
|
| var unwrapped = unwrapIfNeeded(obj);
|
| - if (unwrapped && (needsConstructorFix || obj !== unwrapped)) {
|
| - // Fix up class names for Firefox, or if using the minified polyfill.
|
| - // dart2js prefers .constructor.name, but there are all kinds of cases
|
| - // where this will give the wrong answer.
|
| + if (obj !== unwrapped) {
|
| + // Fix up class names for Firefox.
|
| + // For some of them (like HTMLFormElement and HTMLInputElement),
|
| + // the "constructor" property of the unwrapped nodes points at the
|
| + // same constructor as the wrapper.
|
| var ctor = obj.constructor
|
| if (ctor === unwrapped.constructor) {
|
| var name = ctor._ShadowDOMPolyfill$cacheTag_;
|
|
|