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

Unified Diff: lib/src/custom_element.dart

Issue 957883002: add @CustomElement (Closed) Base URL: git@github.com:dart-lang/web-components.git@master
Patch Set: update pubspec/changelog and add some comments Created 5 years, 10 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 | « CHANGELOG.md ('k') | lib/web_components.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: lib/src/custom_element.dart
diff --git a/lib/src/custom_element.dart b/lib/src/custom_element.dart
new file mode 100644
index 0000000000000000000000000000000000000000..1678fcc57a13dffb061de341e39b63920fe464eb
--- /dev/null
+++ b/lib/src/custom_element.dart
@@ -0,0 +1,22 @@
+// Copyright (c) 2015, 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 web_components.custom_element;
+
+import 'dart:html' show document;
+import 'package:initialize/initialize.dart';
+
+/// Annotation which registers a custom element with the main document.
+class CustomElement implements Initializer<Type> {
+ /// The tag you want to register the class to handle.
+ final String tag;
+
+ /// If this element extends a native html element, then this is the tag that
+ /// represents that element.
+ final String extendsTag;
+
+ const CustomElement(this.tag, {this.extendsTag});
+
+ void initialize(Type t) =>
+ document.registerElement(tag, t, extendsTag: extendsTag);
+}
« no previous file with comments | « CHANGELOG.md ('k') | lib/web_components.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698