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

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

Issue 730223002: Specs: default exports to {} rather than document, since it makes writing modules saner (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Created 6 years, 1 month 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/apis.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 17 matching lines...) Expand all
28 Module API 28 Module API
29 ---------- 29 ----------
30 30
31 Within a script in a module, the ``module`` identifier is bound to 31 Within a script in a module, the ``module`` identifier is bound to
32 the [``Module`` object](apis.md) that represents the module. 32 the [``Module`` object](apis.md) that represents the module.
33 33
34 ### Exporting values ### 34 ### Exporting values ###
35 35
36 A module can export a value by assigning the ``exports`` property of 36 A module can export a value by assigning the ``exports`` property of
37 its ``Module`` object. By default, the ``exports`` property of a 37 its ``Module`` object. By default, the ``exports`` property of a
38 ``Module`` is its ``Document`` object, so that a script-less 38 ``Module`` is an empty Object. Properties can be added to the object,
39 import is still useful (it exposes its contents, e.g. templates that 39 or, it can be set to an entirely different object; for example, it
40 the import might have been written to provide). 40 could be set to the module's Document itself, in case the point of the
41 module is to expose some ``template`` elements.
41 42
42 ### Exporting element definitions ### 43 ### Exporting element definitions ###
43 44
44 When importing a module into another, Sky looks at the properties on 45 When importing a module into another, Sky looks at the properties on
45 the imported module's ``exports`` value, and for each property that is 46 the imported module's ``exports`` value, and for each property that is
46 an element constructor (generated by ``registerElement()``), it adds 47 an element constructor (generated by ``registerElement()``), it adds
47 an element to the importee's element registry. 48 an element to the importee's element registry.
48 49
49 50
50 Naming modules 51 Naming modules
(...skipping 17 matching lines...) Expand all
68 Where ``name_1`` through ``name_n`` are the names bound to the 69 Where ``name_1`` through ``name_n`` are the names bound to the
69 various named imports in the script element's document, 70 various named imports in the script element's document,
70 ``source_code`` is the text content of the script element, 71 ``source_code`` is the text content of the script element,
71 ``source_module`` is the ``Module`` object of the script element's 72 ``source_module`` is the ``Module`` object of the script element's
72 module, and ``value_1`` through ``value_n`` are the values 73 module, and ``value_1`` through ``value_n`` are the values
73 exported by the various named imports in the script element's 74 exported by the various named imports in the script element's
74 document. 75 document.
75 76
76 When an import fails to load, the ``as`` name for the import gets 77 When an import fails to load, the ``as`` name for the import gets
77 bound to ``undefined``. 78 bound to ``undefined``.
OLDNEW
« no previous file with comments | « sky/specs/apis.md ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698