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

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

Issue 695043002: Specs: make element registrations be per-module, define how they are (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
OLDNEW
1 APIs 1 APIs
2 ==== 2 ====
3 3
4 The Sky core API 4 The Sky core API
5 ---------------- 5 ----------------
6 6
7 ```javascript 7 ```javascript
8 module 'sky:core' { 8 module 'sky:core' {
9 9
10 // EVENTS 10 // EVENTS
11 11
12 interface Event { 12 class Event {
13 constructor (String type, Boolean bubbles, any data); // O(1) 13 constructor (String type, Boolean bubbles, any data); // O(1)
14 readonly attribute String type; // O(1) 14 readonly attribute String type; // O(1)
15 readonly attribute Boolean bubbles; // O(1) 15 readonly attribute Boolean bubbles; // O(1)
16 attribute any data; // O(1) 16 attribute any data; // O(1)
17 17
18 readonly attribute EventTarget target; // O(1) 18 readonly attribute EventTarget target; // O(1)
19 void preventDefault(); // O(1) 19 void preventDefault(); // O(1)
20 attribute any result; // O(1) // defaults to undefined 20 attribute any result; // O(1) // defaults to undefined
21 21
22 // TODO(ianh): do events get blocked at scope boundaries, e.g. focus events when both sides are in the scope? 22 // TODO(ianh): do events get blocked at scope boundaries, e.g. focus events when both sides are in the scope?
23 // TODO(ianh): do events ger retargetted, e.g. focus when leaving a custom e lement? 23 // TODO(ianh): do events ger retargetted, e.g. focus when leaving a custom e lement?
24 } 24 }
25 25
26 callback EventListener any (Event event); // return value is assigned to Event .result 26 callback EventListener any (Event event); // return value is assigned to Event .result
27 27
28 interface EventTarget { 28 abstract class EventTarget {
29 any dispatchEvent(Event event); // O(N) in total number of listeners for thi s type in the chain // returns Event.result 29 any dispatchEvent(Event event); // O(N) in total number of listeners for thi s type in the chain // returns Event.result
30 void addEventListener(String type, EventListener listener); // O(1) 30 void addEventListener(String type, EventListener listener); // O(1)
31 void removeEventListener(String type, EventListener listener); // O(N) in ev ent listeners with that type 31 void removeEventListener(String type, EventListener listener); // O(N) in ev ent listeners with that type
32 private Array<String> getRegisteredEventListenerTypes(); // O(N) 32 private Array<String> getRegisteredEventListenerTypes(); // O(N)
33 private Array<EventListener> getRegisteredEventListenersForType(String type) ; // O(N) 33 private Array<EventListener> getRegisteredEventListenersForType(String type) ; // O(N)
34 } 34 }
35 35
36 interface CustomEventTarget : EventTarget { 36 class CustomEventTarget : EventTarget {
37 constructor (); // O(1) 37 constructor (); // O(1)
38 attribute EventTarget parentNode; // getter O(1), setter O(N) in height of t ree, throws if this would make a loop 38 attribute EventTarget parentNode; // getter O(1), setter O(N) in height of t ree, throws if this would make a loop
39 39
40 // you can inherit from this to make your object into an event target 40 // you can inherit from this to make your object into an event target
41 } 41 }
42 42
43 43
44 44
45 // DOM 45 // DOM
46 46
47 typedef ChildNode (Element or Text); 47 typedef ChildNode (Element or Text);
48 typedef ChildArgument (Element or Text or String); 48 typedef ChildArgument (Element or Text or String);
49 49
50 abstract interface Node : EventTarget { 50 abstract class Node : EventTarget {
51 readonly attribute TreeScope? ownerScope; // O(1) 51 readonly attribute TreeScope? ownerScope; // O(1)
52 52
53 readonly attribute ParentNode? parentNode; // O(1) 53 readonly attribute ParentNode? parentNode; // O(1)
54 readonly attribute Element? parentElement; // O(1) // if parentNode isn't an element, returns null 54 readonly attribute Element? parentElement; // O(1) // if parentNode isn't an element, returns null
55 readonly attribute ChildNode? previousSibling; // O(1) 55 readonly attribute ChildNode? previousSibling; // O(1)
56 readonly attribute ChildNode? nextSibling; // O(1) 56 readonly attribute ChildNode? nextSibling; // O(1)
57 57
58 // the following all throw if parentNode is null 58 // the following all throw if parentNode is null
59 void insertBefore(ChildArgument... nodes); // O(N) in number of arguments pl us all their descendants 59 void insertBefore(ChildArgument... nodes); // O(N) in number of arguments pl us all their descendants
60 void insertAfter(ChildArgument... nodes); // O(N) in number of arguments plu s all their descendants 60 void insertAfter(ChildArgument... nodes); // O(N) in number of arguments plu s all their descendants
61 void replaceWith(ChildArgument... nodes); // O(N) in number of descendants p lus arguments plus all their descendants 61 void replaceWith(ChildArgument... nodes); // O(N) in number of descendants p lus arguments plus all their descendants
62 void remove(); // O(N) in number of descendants 62 void remove(); // O(N) in number of descendants
63 Node cloneNode(Boolean deep); // O(1) if deep=false, O(N) in the number of d escendants if deep=true 63 Node cloneNode(Boolean deep); // O(1) if deep=false, O(N) in the number of d escendants if deep=true
64 64
65 // called when parentNode changes 65 // called when parentNode changes
66 virtual void parentChangeCallback(ParentNode? oldParent, ParentNode? newPare nt, ChildNode? previousSibling, ChildNode? nextSibling); // O(N) in descendants (calls attached/detached) 66 virtual void parentChangeCallback(ParentNode? oldParent, ParentNode? newPare nt, ChildNode? previousSibling, ChildNode? nextSibling); // O(N) in descendants (calls attached/detached)
67 virtual void attachedCallback(); // noop 67 virtual void attachedCallback(); // noop
68 virtual void detachedCallback(); // noop 68 virtual void detachedCallback(); // noop
69 } 69 }
70 70
71 abstract interface ParentNode : Node { 71 abstract class ParentNode : Node {
72 readonly attribute ChildNode? firstChild; // O(1) 72 readonly attribute ChildNode? firstChild; // O(1)
73 readonly attribute ChildNode? lastChild; // O(1) 73 readonly attribute ChildNode? lastChild; // O(1)
74 74
75 // Returns a new Array every time. 75 // Returns a new Array every time.
76 Array<ChildNode> getChildNodes(); // O(N) in number of child nodes 76 Array<ChildNode> getChildNodes(); // O(N) in number of child nodes
77 Array<Element> getChildElements(); // O(N) in number of child nodes // TODO( ianh): might not be necessary if we have the parser drop unnecessary whitespace text nodes 77 Array<Element> getChildElements(); // O(N) in number of child nodes // TODO( ianh): might not be necessary if we have the parser drop unnecessary whitespace text nodes
78 78
79 void append(ChildArgument... nodes); // O(N) in number of arguments plus all their descendants 79 void append(ChildArgument... nodes); // O(N) in number of arguments plus all their descendants
80 void prepend(ChildArgument... nodes); // O(N) in number of arguments plus al l their descendants 80 void prepend(ChildArgument... nodes); // O(N) in number of arguments plus al l their descendants
81 void replaceChildrenWith(ChildArgument... nodes); // O(N) in number of desce ndants plus arguments plus all their descendants 81 void replaceChildrenWith(ChildArgument... nodes); // O(N) in number of desce ndants plus arguments plus all their descendants
82 } 82 }
83 83
84 interface Attr { 84 class Attr {
85 constructor (String name, String value); // O(1) 85 constructor (String name, String value); // O(1)
86 readonly attribute String name; // O(1) 86 readonly attribute String name; // O(1)
87 readonly attribute String value; // O(1) 87 readonly attribute String value; // O(1)
88 } 88 }
89 89
90 interface Element : ParentNode { 90 abstract class Element : ParentNode {
esprehn 2014/10/31 23:13:44 Do we get rid of "upgrade" ? Right now custom elem
91 readonly attribute String tagName; // O(1) 91 readonly attribute String tagName; // O(1)
92 92
93 Boolean hasAttribute(String name); // O(N) in arguments 93 Boolean hasAttribute(String name); // O(N) in arguments
94 String getAttribute(String name); // O(N) in arguments 94 String getAttribute(String name); // O(N) in arguments
95 void setAttribute(String name, String value); // O(N) in arguments 95 void setAttribute(String name, String value); // O(N) in arguments
96 void removeAttribute(String name); // O(N) in arguments 96 void removeAttribute(String name); // O(N) in arguments
97 97
98 // Returns a new Array and new Attr instances every time. 98 // Returns a new Array and new Attr instances every time.
99 Array<Attr> getAttributes(); // O(N) in arguments 99 Array<Attr> getAttributes(); // O(N) in arguments
100 100
101 readonly attribute ShadowRoot? shadowRoot; // O(1) // returns the shadow roo t 101 readonly attribute ShadowRoot? shadowRoot; // O(1) // returns the shadow roo t
102 Array<ContentElement> getDestinationInsertionPoints(); // O(N) in number of insertion points the node is in 102 Array<ContentElement> getDestinationInsertionPoints(); // O(N) in number of insertion points the node is in
103 103
104 virtual void attributeChangeCallback(String name, String? oldValue, String? newValue); // noop 104 virtual void attributeChangeCallback(String name, String? oldValue, String? newValue); // noop
105 // TODO(ianh): does a node ever need to know when it's been redistributed? 105 // TODO(ianh): does a node ever need to know when it's been redistributed?
106 } 106 }
107 Element createElement(String tagName, Dictionary attributes, ChildArguments... nodes); // O(M+N), M = number of attributes, N = number of nodes plus all their descendants
108 Element createElement(String tagName, Dictionary attributes); // shorthand
109 Element createElement(String tagName, ChildArguments... nodes); // shorthand
110 Element createElement(String tagName); // shorthand
111 107
112 dictionary ElementRegistration { 108 class Text : Node {
113 String tagName;
114 Boolean shadow;
115 Object prototype;
116 }
117 Object registerElement(ElementRegistration options); // O(N) in number of outs tanding elements with that tag name to be upgraded
118
119 interface Text : Node {
120 constructor (String value); // O(1) 109 constructor (String value); // O(1)
121 attribute String value; // O(1) 110 attribute String value; // O(1)
122 111
123 void replaceWith(String node); // O(1) // special case override of Node.repl aceWith() 112 void replaceWith(String node); // O(1) // special case override of Node.repl aceWith()
124 113
125 virtual void valueChangeCallback(String? oldValue, String? newValue); // noo p 114 virtual void valueChangeCallback(String? oldValue, String? newValue); // noo p
126 } 115 }
127 116
128 interface DocumentFragment : ParentNode { 117 class DocumentFragment : ParentNode {
129 constructor (ChildArguments... nodes); // O(N) in number of arguments plus a ll their descendants 118 constructor (ChildArguments... nodes); // O(N) in number of arguments plus a ll their descendants
130 } 119 }
131 120
132 abstract interface TreeScope : ParentNode { 121 abstract class TreeScope : ParentNode {
133 readonly attribute Document? ownerDocument; // O(1) 122 readonly attribute Document? ownerDocument; // O(1)
134 readonly attribute TreeScope? parentScope; // O(1) 123 readonly attribute TreeScope? parentScope; // O(1)
135 124
136 Element? findId(String id); // O(1) 125 Element? findId(String id); // O(1)
137 } 126 }
138 127
139 interface ShadowRoot : TreeScope { 128 class ShadowRoot : TreeScope {
140 constructor (Element host); // O(1) // note that there is no way in the API to use a newly created ShadowRoot 129 constructor (Element host); // O(1) // note that there is no way in the API to use a newly created ShadowRoot
141 readonly attribute Element host; // O(1) 130 readonly attribute Element host; // O(1)
142 } 131 }
143 132
144 interface Document : TreeScope { 133 class Document : TreeScope {
145 constructor (ChildArguments... nodes); // O(N) in number of arguments plus a ll their descendants 134 constructor (ChildArguments... nodes); // O(N) in number of arguments plus a ll their descendants
146 } 135 }
147 136
148 interface SelectorQuery { 137 class SelectorQuery {
149 constructor (String selector); // O(F()) where F() is the complexity of the selector 138 constructor (String selector); // O(F()) where F() is the complexity of the selector
150 139
151 Boolean matches(Element element); // O(F()) 140 Boolean matches(Element element); // O(F())
152 Element? find(ParentNode root); // O(N*F()) where N is the number of descend ants 141 Element? find(ParentNode root); // O(N*F()) where N is the number of descend ants
153 Array<Element> findAll(ParentNode root); // O(N*F()) where N is the number o f descendants 142 Array<Element> findAll(ParentNode root); // O(N*F()) where N is the number o f descendants
154 } 143 }
155 144
156 // Built-in Elements 145 // Built-in Elements
157 interface ImportElement : Element { } 146 class ImportElement : Element {
158 interface TemplateElement : Element { 147 constructor (Dictionary attributes, ChildArguments... nodes); // O(M+N), M = number of attributes, N = number of nodes plus all their descendants
148 constructor (ChildArguments... nodes); // shorthand
149 constructor (Dictionary attributes); // shorthand
150 constructor (); // shorthand
151 }
152 class TemplateElement : Element {
153 constructor (Dictionary attributes, ChildArguments... nodes); // O(M+N), M = number of attributes, N = number of nodes plus all their descendants
154 constructor (ChildArguments... nodes); // shorthand
155 constructor (Dictionary attributes); // shorthand
156 constructor (); // shorthand
159 readonly attribute DocumentFragment content; // O(1) 157 readonly attribute DocumentFragment content; // O(1)
160 } 158 }
161 interface ScriptElement : Element { } 159 class ScriptElement : Element {
162 interface StyleElement : Element { } 160 constructor (Dictionary attributes, ChildArguments... nodes); // O(M+N), M = number of attributes, N = number of nodes plus all their descendants
163 interface ContentElement : Element { 161 constructor (ChildArguments... nodes); // shorthand
162 constructor (Dictionary attributes); // shorthand
163 constructor (); // shorthand
164 }
165 class StyleElement : Element {
166 constructor (Dictionary attributes, ChildArguments... nodes); // O(M+N), M = number of attributes, N = number of nodes plus all their descendants
167 constructor (ChildArguments... nodes); // shorthand
168 constructor (Dictionary attributes); // shorthand
169 constructor (); // shorthand
170 }
171 class ContentElement : Element {
172 constructor (Dictionary attributes, ChildArguments... nodes); // O(M+N), M = number of attributes, N = number of nodes plus all their descendants
173 constructor (ChildArguments... nodes); // shorthand
174 constructor (Dictionary attributes); // shorthand
175 constructor (); // shorthand
164 Array<Node> getDistributedNodes(); // O(N) in distributed nodes 176 Array<Node> getDistributedNodes(); // O(N) in distributed nodes
165 } 177 }
166 interface ImgElement : Element { } 178 class ImgElement : Element {
167 interface IframeElement : Element { } 179 constructor (Dictionary attributes, ChildArguments... nodes); // O(M+N), M = number of attributes, N = number of nodes plus all their descendants
168 interface TElement : Element { } 180 constructor (ChildArguments... nodes); // shorthand
169 interface AElement : Element { } 181 constructor (Dictionary attributes); // shorthand
170 interface TitleElement : Element { } 182 constructor (); // shorthand
183 }
184 class IframeElement : Element {
185 constructor (Dictionary attributes, ChildArguments... nodes); // O(M+N), M = number of attributes, N = number of nodes plus all their descendants
186 constructor (ChildArguments... nodes); // shorthand
187 constructor (Dictionary attributes); // shorthand
188 constructor (); // shorthand
189 }
190 class TElement : Element {
191 constructor (Dictionary attributes, ChildArguments... nodes); // O(M+N), M = number of attributes, N = number of nodes plus all their descendants
192 constructor (ChildArguments... nodes); // shorthand
193 constructor (Dictionary attributes); // shorthand
194 constructor (); // shorthand
195 }
196 class AElement : Element {
197 constructor (Dictionary attributes, ChildArguments... nodes); // O(M+N), M = number of attributes, N = number of nodes plus all their descendants
198 constructor (ChildArguments... nodes); // shorthand
199 constructor (Dictionary attributes); // shorthand
200 constructor (); // shorthand
201 }
202 class TitleElement : Element {
203 constructor (Dictionary attributes, ChildArguments... nodes); // O(M+N), M = number of attributes, N = number of nodes plus all their descendants
204 constructor (ChildArguments... nodes); // shorthand
205 constructor (Dictionary attributes); // shorthand
206 constructor (); // shorthand
207 }
171 208
172 209
173 210
211 dictionary ElementRegistration {
212 String tagName;
213 Boolean shadow;
214 Object prototype;
215 }
216
217 interface ElementConstructor {
218 constructor (Dictionary attributes, ChildArguments... nodes); // O(M+N), M = number of attributes, N = number of nodes plus all their descendants
219 constructor (ChildArguments... nodes); // shorthand
220 constructor (Dictionary attributes); // shorthand
221 constructor (); // shorthand
222
223 constructor attribute String tagName;
224 }
225
174 // MODULES 226 // MODULES
175 abstract interface AbstractModule : EventTarget { 227 abstract class AbstractModule : EventTarget {
228 readonly attribute Document document; // O(1) // the Documentof the module o r application
176 Promise<any> import(String url); // O(Yikes) // returns the module's exports 229 Promise<any> import(String url); // O(Yikes) // returns the module's exports
230
231 // createElement() lets you create elements that will be upgraded later when you register the element
232 Element createElement(String tagName, Dictionary attributes, ChildArguments. .. nodes); // O(M+N), M = number of attributes, N = number of nodes plus all the ir descendants
233 Element createElement(String tagName, Dictionary attributes); // shorthand
234 Element createElement(String tagName, ChildArguments... nodes); // shorthand
235 Element createElement(String tagName); // shorthand
236
237 ElementConstructor registerElement(ElementRegistration options); // O(N) in number of outstanding elements with that tag name to be upgraded
238
177 ScriptElement? currentScript; // O(1) // returns the <script> element curren tly being executed if any, and if it's in this module; else null 239 ScriptElement? currentScript; // O(1) // returns the <script> element curren tly being executed if any, and if it's in this module; else null
178 } 240 }
179 241
180 interface Module : AbstractModule { 242 class Module : AbstractModule {
181 constructor (Application application, Document document); // O(1) 243 constructor (Application application, Document document); // O(1)
244 readonly attribute Application application; // O(1)
245
182 attribute any exports; // O(1) // defaults to the module's document 246 attribute any exports; // O(1) // defaults to the module's document
183 readonly attribute Document document; // O(1) // the module's document
184 readonly attribute Application application; // O(1)
185 } 247 }
186 248
187 interface Application : AbstractModule { 249 class Application : AbstractModule {
188 constructor (Document document); // O(1) 250 constructor (Document document); // O(1)
189 attribute String title; // O(1) 251 attribute String title; // O(1)
190 readonly attribute Document document; // O(1) // the application's document
191 } 252 }
192 253
193 // see script.md for a description of the global object, though note that 254 // see script.md for a description of the global object, though note that
194 // the sky core module doesn't use it or affect it in any way. 255 // the sky core module doesn't use it or affect it in any way.
195 256
196 } 257 }
197 ``` 258 ```
198 259
260 TODO(ianh): is it ok that you can do
261 module.application.registerElement()? we need application so that a
262 module can implement <title> and get to application.title...
263
199 TODO(ianh): event loop 264 TODO(ianh): event loop
200 265
201 TODO(ianh): define the DOM APIs listed above, including firing the 266 TODO(ianh): define the DOM APIs listed above, including firing the
202 change callbacks 267 change callbacks
203 268
204 TODO(ianh): schedule microtask, schedule task, requestAnimationFrame, 269 TODO(ianh): schedule microtask, schedule task, requestAnimationFrame,
205 custom element callbacks... 270 custom element callbacks...
206 271
207 272
208 273
(...skipping 13 matching lines...) Expand all
222 Sky IDL works more or less the same as Web IDL but the syntax is a bit 287 Sky IDL works more or less the same as Web IDL but the syntax is a bit
223 different. 288 different.
224 289
225 ```javascript 290 ```javascript
226 module 'sky:modulename' { 291 module 'sky:modulename' {
227 292
228 // this is a comment 293 // this is a comment
229 294
230 typedef NewType OldType; // useful when OldType is a commonly-used union 295 typedef NewType OldType; // useful when OldType is a commonly-used union
231 296
232 interface InterfaceName { 297 class ClassName {
233 // an interface corresponds to a JavaScript prototype 298 // a class corresponds to a JavaScript prototype
299 // corresponds to a WebIDL 'interface'
234 } 300 }
235 301
236 abstract interface Superinterface { 302 abstract class Superclass {
237 // an abstract interface can't have a constructor 303 // an abstract class can't have a constructor
238 // in every other respect it is the same as a regular interface 304 // in every other respect it is the same as a regular class
239 } 305 }
240 306
241 interface Subinterface : Superinterface { 307 class Subclass : Superclass {
242 // properties 308 // properties
243 readonly attribute ReturnType attributeName; // getter 309 readonly attribute ReturnType attributeName; // getter
244 attribute ReturnType attributeName; // getter and setter 310 attribute ReturnType attributeName; // getter and setter
245 311
246 // methods and constructors 312 // methods and constructors
247 constructor (); 313 constructor ();
248 ReturnType method(); 314 ReturnType method();
249 // When the platform calls this method, it always invokes the "real" metho d, even if it's been 315 // When the platform calls this method, it always invokes the "real" metho d, even if it's been
250 // deleted from the prototypes (as if it took a reference to the method at startup, and stored 316 // deleted from the prototypes (as if it took a reference to the method at startup, and stored
251 // state using Symbols) 317 // state using Symbols)
252 virtual ReturnType methodCallback(); 318 virtual ReturnType methodCallback();
253 // when the platform calls this, it actually calls it the way JS would, so author overrides do 319 // when the platform calls this, it actually calls it the way JS would, so author overrides do
254 // affect what gets called. Make sure if you override it that you call the superclass implementation! 320 // affect what gets called. Make sure if you override it that you call the superclass implementation!
255 // The default implementations of 'virtual' methods all end by calling the identically named method 321 // The default implementations of 'virtual' methods all end by calling the identically named method
256 // on the superclass, if there is such a method. 322 // on the superclass, if there is such a method.
257 323
324 // properties on the constructor
325 constructor readonly attribute ReturnType staticName;
326
258 // private APIs - see below 327 // private APIs - see below
259 private void method(); 328 private void method();
260 329
261 // arguments and overloading are done as follows 330 // arguments and overloading are done as follows
262 // note that the argument names are only for documentation purposes 331 // note that the argument names are only for documentation purposes
263 ReturnType method(ArgumentType argumentName1, ArgumentType argumentName2); 332 ReturnType method(ArgumentType argumentName1, ArgumentType argumentName2);
264 // the last argument's type can have "..." appended to it to indicate a vara rgs-like situation 333 // the last argument's type can have "..." appended to it to indicate a vara rgs-like situation
265 ReturnType method(ArgumentType argumentName1, ArgumentType... allSubsequentA rguments); 334 ReturnType method(ArgumentType argumentName1, ArgumentType... allSubsequentA rguments);
266 } 335 }
267 336
268 dictionary Options { 337 dictionary Options {
269 String foo; 338 String foo;
270 Integer bar; 339 Integer bar;
271 } 340 }
272 341
273 // the module can have properties and methods also 342 // the module can have properties and methods also
274 attribute String Foo; 343 attribute String Foo;
275 void method(); 344 void method();
276 345
346 interface InterfaceName {
347 // describes a template of a prototype, in the same syntax as a class
348 // not actually exposed in the runtime
349 }
350
277 } 351 }
278 ``` 352 ```
279 353
280 ### Private APIs ### 354 ### Private APIs ###
281 355
282 Private APIs are only accessible via Symbol objects, which are then 356 Private APIs are only accessible via Symbol objects, which are then
283 exposed on the sky:debug module's exports object as the name of the 357 exposed on the sky:debug module's exports object as the name of the
284 member given in the IDL. 358 member given in the IDL.
285 359
286 For example, consider: 360 For example, consider:
287 361
288 ```javascript 362 ```javascript
289 interface Foo { 363 class Foo {
290 private void Bar(); 364 private void Bar();
291 } 365 }
292 ``` 366 ```
293 367
294 In a script with a ``foo`` object of type ``Foo``, ``foo.Bar`` is 368 In a script with a ``foo`` object of type ``Foo``, ``foo.Bar`` is
295 undefined. However, it can be obtained as follows: 369 undefined. However, it can be obtained as follows:
296 370
297 ```html 371 ```html
298 <import src="sky:debug" as="debug"/> 372 <import src="sky:debug" as="debug"/>
299 <!-- ... import whatever defines 'foo' ... --> 373 <!-- ... import whatever defines 'foo' ... -->
300 <script> 374 <script>
301 foo[debug.Bar] 375 foo[debug.Bar]
302 </script> 376 </script>
303 ``` 377 ```
304 378
305 ### Types ### 379 ### Types ###
306 380
307 The following types are available: 381 The following types are available:
308 382
309 * ``Integer`` - WebIDL ``long long`` 383 * ``Integer`` - WebIDL ``long long``
310 * ``Float`` - WebIDL ``double`` 384 * ``Float`` - WebIDL ``double``
311 * ``String`` - WebIDL ``USVString`` 385 * ``String`` - WebIDL ``USVString``
312 * ``Boolean`` - WebIDL ``boolean`` 386 * ``Boolean`` - WebIDL ``boolean``
313 # ``Object`` - WebIDL ``object`` 387 # ``Object`` - WebIDL ``object``
314 * ``InterfaceName`` - an instance of the interface InterfaceName 388 * ``ClassName`` - an instance of the class ClassName
315 * ``DictionaryName`` - an instance of the dictionary DictionaryName 389 * ``DictionaryName`` - an instance of the dictionary DictionaryName
316 * ``Promise<Type>`` - WebIDL ``Promise<T>`` 390 * ``Promise<Type>`` - WebIDL ``Promise<T>``
317 * ``Array<Type>`` - WebIDL ``sequence<T>`` 391 * ``Array<Type>`` - WebIDL ``sequence<T>``
318 * ``Dictionary`` - unordered set of name-value String-String pairs with no dupli cate names 392 * ``Dictionary`` - unordered set of name-value String-String pairs with no dupli cate names
319 * ``Type?`` - union of Type and the singleton type with value "null" (WebIDL nul lable) 393 * ``Type?`` - union of Type and the singleton type with value "null" (WebIDL nul lable)
320 * ``(Type1 or Type2)`` - union of Type1 and Type2 (WebIDL union) 394 * ``(Type1 or Type2)`` - union of Type1 and Type2 (WebIDL union)
321 * ``any`` - union of all types (WebIDL ``any``) 395 * ``any`` - union of all types (WebIDL ``any``)
322 396
323 Methods that return nothing (undefined, in JS) use the keyword "void" 397 Methods that return nothing (undefined, in JS) use the keyword "void"
324 instead of a type. 398 instead of a type.
(...skipping 24 matching lines...) Expand all
349 the core mojo fabric JS API sky:mojo:fabric:core 423 the core mojo fabric JS API sky:mojo:fabric:core
350 the asyncWait/cancelWait mojo fabric JS API (interface to IPC thread) sky:moj o:fabric:ipc 424 the asyncWait/cancelWait mojo fabric JS API (interface to IPC thread) sky:moj o:fabric:ipc
351 the mojom for the shell, proxying through C++ so that the shell pipe isn't exp osed sky:mojo:shell 425 the mojom for the shell, proxying through C++ so that the shell pipe isn't exp osed sky:mojo:shell
352 the sky API sky:core 426 the sky API sky:core
353 the sky debug symbols for private APIs sky:debug 427 the sky debug symbols for private APIs sky:debug
354 ``` 428 ```
355 429
356 TODO(ianh): determine if we want to separate the "this" from the 430 TODO(ianh): determine if we want to separate the "this" from the
357 Document, especially for Modules, so that exposing a module's element 431 Document, especially for Modules, so that exposing a module's element
358 doesn't expose the module's exports attribute. 432 doesn't expose the module's exports attribute.
OLDNEW
« sky/README.md ('K') | « sky/examples/radio.sky ('k') | sky/specs/modules.md » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698