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

Unified Diff: runtime/observatory/lib/src/elements/helpers/tag.dart

Issue 2119733003: Wrapping leaf nodes in non polymer elements (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Converted error-ref tag Created 4 years, 5 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: runtime/observatory/lib/src/elements/helpers/tag.dart
diff --git a/runtime/observatory/lib/src/elements/helpers/tag.dart b/runtime/observatory/lib/src/elements/helpers/tag.dart
new file mode 100644
index 0000000000000000000000000000000000000000..386dedd197a7330d89e30938e0c1794e965a3858
--- /dev/null
+++ b/runtime/observatory/lib/src/elements/helpers/tag.dart
@@ -0,0 +1,28 @@
+// Copyright (c) 2016, 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.
+
+import 'dart:html';
+
+class Tag<T> {
+ final String name;
+
+ const Tag(this.name);
+
+ static final Map<Type, String> _tagByClass = <Type, String>{};
+ static final Map<String, Type> _classByTag = <String, Type>{};
+
+ void ensureRegistration() {
+ if (!_tagByClass.containsKey(T) && !_classByTag.containsKey(name)) {
+ document.registerElement(name, T);
+ _tagByClass[T] = name;
+ _classByTag[name] = T;
+ }
+ if (_tagByClass[T] != name)
+ throw new ArgumentError(
+ 'Class $T is already registered to tag ${_tagByClass[T]}');
+ if (_classByTag[name] != T)
+ throw new ArgumentError(
+ 'Tag $name is already registered by class ${_classByTag[name]}');
+ }
+}

Powered by Google App Engine
This is Rietveld 408576698