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

Side by Side Diff: sky/specs/modules.md

Issue 944873007: Specs: define how importing element registrations works, move built-in elements to a separate modul… (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 unified diff | Download patch
« no previous file with comments | « sky/specs/gestures.md ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 Sky Module System 1 Sky Module System
2 ================= 2 =================
3 3
4 This document describes the Sky module system. 4 This document describes the Sky module system.
5 5
6 Overview 6 Overview
7 -------- 7 --------
8 8
9 The Sky module system is based on the ``import`` element. In its 9 The Sky module system is based on the ``import`` element. In its
10 most basic form, you import a module as follows: 10 most basic form, you import a module as follows:
(...skipping 13 matching lines...) Expand all
24 module waits until its list of outstanding dependencies is empty 24 module waits until its list of outstanding dependencies is empty
25 before marking itself complete. 25 before marking itself complete.
26 26
27 The ``as`` attribute on the ``import`` element binds a name to the 27 The ``as`` attribute on the ``import`` element binds a name to the
28 imported module: 28 imported module:
29 29
30 ```html 30 ```html
31 <import src="path/to/chocolate.sky" as="chocolate" /> 31 <import src="path/to/chocolate.sky" as="chocolate" />
32 ``` 32 ```
33 33
34 Each module implicitly imports the [Built-In Elements
35 Module](builtins.md).
36
37 When a module imports another, and the ``import`` element has no
38 ``as`` attribute, then any elements registered in that module whose
39 tag names do not begin with an underscore must be registered on the
40 importing module. (If multiple elements are registered with the same
41 name, that name gets marked as dead for that module and all the
42 registrations for that name are discarded.)
43
44 TODO(ianh): decide if elements imported with "as" should be imported
45 but with the "as" name prefixed, as in ``<foo.button>``
46
34 47
35 Module API 48 Module API
36 ---------- 49 ----------
37 50
38 Each module consists of one or more libraries. The first library in a 51 Each module consists of one or more libraries. The first library in a
39 module is the *element tree library*, which imports the dart:sky 52 module is the *element tree library*, which consists of the following
40 module and then consists of the following code for a Sky module: 53 code for a Sky module:
41 54
42 ```dart 55 ```dart
56 import 'dart:sky';
43 final Module module = new Module(); 57 final Module module = new Module();
44 ``` 58 ```
45 59
46 ...and the following code for a Sky application: 60 ...and the following code for a Sky application:
47 61
48 ```dart 62 ```dart
63 import 'dart:sky';
49 final Module module = new Application(); 64 final Module module = new Application();
50 ``` 65 ```
51 66
52 The ``<script>`` elements found in the module's element tree create 67 The ``<script>`` elements found in the module's element tree create
53 the subsequent libraries. Each one first imports the ``dart:mirror`` 68 the subsequent libraries. Each one first imports the ``dart:mirror``
54 library, then the ``dart:sky`` module, then the first library 69 library, then the ``dart:sky`` module, then the first library
55 described above, then all the modules referenced by ``<import>`` 70 described above, then all the modules referenced by ``<import>``
56 element up to that ``<script>`` element and all the libraries defined 71 element up to that ``<script>`` element and all the libraries defined
57 by ``<script>`` elements up to that point, interleaved so as to 72 by ``<script>`` elements up to that point, interleaved so as to
58 maintain the same relative order as those elements were first seen by 73 maintain the same relative order as those elements were first seen by
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
124 } 139 }
125 140
126 class Application extends AbstractModule { 141 class Application extends AbstractModule {
127 Application({String url, Root elements, this.gestureManager}) : 142 Application({String url, Root elements, this.gestureManager}) :
128 super(url: url, elements: elements); // O(1) 143 super(url: url, elements: elements); // O(1)
129 external String get title; // O(1) 144 external String get title; // O(1)
130 external void set title(String newValue); // O(1) 145 external void set title(String newValue); // O(1)
131 final GestureManager gestureManager; 146 final GestureManager gestureManager;
132 } 147 }
133 ``` 148 ```
OLDNEW
« no previous file with comments | « sky/specs/gestures.md ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698