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

Unified Diff: dart/site/try/src/shadow_root.dart

Issue 261413002: Use ShadowRoot to hide non-user content (for example, diagnostics). (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge
Patch Set: Address Kasper's comments. 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
« no previous file with comments | « dart/site/try/src/interaction_manager.dart ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: dart/site/try/src/shadow_root.dart
diff --git a/dart/site/try/src/shadow_root.dart b/dart/site/try/src/shadow_root.dart
new file mode 100644
index 0000000000000000000000000000000000000000..9ba086fac5fd36e0583bb6d568588473d896ce87
--- /dev/null
+++ b/dart/site/try/src/shadow_root.dart
@@ -0,0 +1,41 @@
+// 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.
+
+library trydart.shadow_root;
+
+import 'dart:html';
+
+void setShadowRoot(Element node, text) {
+ if (text is String) {
+ text = new Text(text);
+ }
+ getShadowRoot(node)
+ ..nodes.clear()
+ ..append(text);
+}
+
+
+/* ShadowRoot or Element */ getShadowRoot(Element node) {
+ if (ShadowRoot.supported) {
+ ShadowRoot root = node.shadowRoot;
+ return root != null ? root : node.createShadowRoot();
+ } else {
+ Element root = node.querySelector('[try-dart-shadow-root]');
+ if (root == null) {
+ root = new SpanElement()
+ ..setAttribute('try-dart-shadow-root', '');
+ node.append(root);
+ }
+ return root;
+ }
+}
+
+void removeShadowRootPolyfill(Element root) {
+ if (!ShadowRoot.supported) {
+ List<Node> polyfill = root.querySelectorAll('[try-dart-shadow-root]');
+ for (Element element in polyfill) {
+ element.remove();
+ }
+ }
+}
« no previous file with comments | « dart/site/try/src/interaction_manager.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698