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

Unified Diff: src/site/docs/tutorials/fetchdata/examples/its_all_about_you/web/packages/web_components/dart_support.js

Issue 275613002: Update polymer tutorial; make directory paths match new sample structure (Closed) Base URL: https://github.com/dart-lang/dartlang.org.git@master
Patch Set: probably nothing (oh app engine you joker) Created 6 years, 7 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 side-by-side diff with in-line comments
Download patch
Index: src/site/docs/tutorials/fetchdata/examples/its_all_about_you/web/packages/web_components/dart_support.js
diff --git a/src/site/docs/tutorials/fetchdata/examples/its_all_about_you/web/packages/web_components/dart_support.js b/src/site/docs/tutorials/fetchdata/examples/its_all_about_you/web/packages/web_components/dart_support.js
new file mode 100644
index 0000000000000000000000000000000000000000..44b5a38cad1912c75ad8e8b5be586d05e845aa86
--- /dev/null
+++ b/src/site/docs/tutorials/fetchdata/examples/its_all_about_you/web/packages/web_components/dart_support.js
@@ -0,0 +1,61 @@
+// 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.
+
+(function() {
+ var ShadowDOMPolyfill = window.ShadowDOMPolyfill;
+ if (!ShadowDOMPolyfill) return;
+
+ 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.");
+ }
+
+ var needsConstructorFix = window.constructor === window.Window;
+
+ // TODO(jmesserly): we need to wrap document somehow (a dart:html hook?)
+ window.dartExperimentalFixupGetTag = function(originalGetTag) {
+ var NodeList = ShadowDOMPolyfill.wrappers.NodeList;
+ var ShadowRoot = ShadowDOMPolyfill.wrappers.ShadowRoot;
+ var unwrapIfNeeded = ShadowDOMPolyfill.unwrapIfNeeded;
+ function getTag(obj) {
+ // TODO(jmesserly): do we still need these?
+ if (obj instanceof NodeList) return 'NodeList';
+ if (obj instanceof ShadowRoot) return 'ShadowRoot';
+ if (MutationRecord && (obj instanceof MutationRecord))
+ return 'MutationRecord';
+ if (MutationObserver && (obj instanceof MutationObserver))
+ return 'MutationObserver';
+
+ // TODO(jmesserly): this prevents incorrect interaction between ShadowDOM
+ // and dart:html's <template> polyfill. Essentially, ShadowDOM is
+ // polyfilling native template, but our Dart polyfill fails to detect this
+ // because the unwrapped node is an HTMLUnknownElement, leading it to
+ // think the node has no content.
+ 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.
+ var ctor = obj.constructor
+ if (ctor === unwrapped.constructor) {
+ var name = ctor._ShadowDOMPolyfill$cacheTag_;
+ if (!name) {
+ name = Object.prototype.toString.call(unwrapped);
+ name = name.substring(8, name.length - 1);
+ ctor._ShadowDOMPolyfill$cacheTag_ = name;
+ }
+ return name;
+ }
+
+ obj = unwrapped;
+ }
+ return originalGetTag(obj);
+ }
+
+ return getTag;
+ };
+})();

Powered by Google App Engine
This is Rietveld 408576698