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

Unified Diff: sky/specs/dom.md

Issue 908983002: Specs: Element registration in the Dart world (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: 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 | « no previous file | sky/specs/modules.md » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: sky/specs/dom.md
diff --git a/sky/specs/dom.md b/sky/specs/dom.md
index 34a5a159dc350e0270a97363a6ea963b3c86d22f..02070e0c4fd451bb71c1776ce74181dbee47fb97 100644
--- a/sky/specs/dom.md
+++ b/sky/specs/dom.md
@@ -79,16 +79,26 @@ class Attr {
// @tagname annotation for registering elements
// only useful when placed on classes that inherit from Element
-class tagname {
- const tagname(this.value);
- @nonnull final String value;
+class tagname extends AutomaticMetadata {
+ const tagname(this.name);
+ @nonnull final String name;
+ void init(DeclarationMirror target, Module module) {
+ assert(target is ClassMirror);
+ if (!target.isSubclassOf(reflectClass(Element)))
+ throw Error('@tagname can only be used on descendants of Element');
+ module.registerElement(name, (target as ClassMirror).reflectedType);
+ }
}
abstract class FindRoot { }
abstract class Element extends ParentNode with ChildNode implements FindRoot {
- Element({Map</*@nonnull*/ String, /*@nonnull*/ String> attributes: null,
- List</*nonnull*/ ChildNode> nodes: null}); // O(M+N), M = number of attributes, N = number of nodes plus all their descendants
+ external Element({Map</*@nonnull*/ String, /*@nonnull*/ String> attributes: null,
+ List</*nonnull*/ ChildNode> nodes: null,
+ Module hostModule: null}); // O(M+N), M = number of attributes, N = number of nodes plus all their descendants
+ // initialises the internal attributes table
+ // appends the given child nodes
+ // if this.needsShadow, creates a shadow tree
@nonnull String get tagName { // O(N) in number of annotations on the class
// throws a StateError if the class doesn't have an @tagname annotation
@@ -104,6 +114,7 @@ abstract class Element extends ParentNode with ChildNode implements FindRoot {
// Returns a new Array and new Attr instances every time.
@nonnull external List<Attr> getAttributes(); // O(N) in number of attributes
+ get bool needsShadow => false; // O(1)
external ShadowRoot get shadowRoot; // O(1)
// returns the shadow root
// TODO(ianh): Should this be mutable? It would help explain how it gets set...
« no previous file with comments | « no previous file | sky/specs/modules.md » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698