Specs: custom element constructor argument shouldn't clash with the module-global 'module' identifier
Review URL: https://codereview.chromium.org/829133003
diff --git a/sky/examples/calculator/buttons.sky b/sky/examples/calculator/buttons.sky
index 29c59c3..07b32e0 100644
--- a/sky/examples/calculator/buttons.sky
+++ b/sky/examples/calculator/buttons.sky
@@ -3,8 +3,8 @@
<script>
class AbstractButton extends Element {
- constructor (module) {
- super(module);
+ constructor (hostModule) {
+ super(hostModule);
let selector = new SelectorQuery('.dynamic');
this.addEventListener('pointer-down', (event) => {
selector.findAll(this.shadowRoot).every((element) => element.setAttribute('clicked'));
@@ -59,8 +59,8 @@
class extends AbstractButton {
static get tagName() { return 'graybutton'; }
static get shadow() { return true; }
- constructor (module) {
- super(module);
+ constructor (hostModule) {
+ super(hostModule);
this.shadowRoot.append(module.document.findId('threed-button-shadow-tree').cloneNode(true));
}
}
@@ -69,8 +69,8 @@
class extends AbstractButton {
static get tagName() { return 'flatbutton'; }
static get shadow() { return true; }
- constructor (module) {
- super(module);
+ constructor (hostModule) {
+ super(hostModule);
this.shadowRoot.append(module.document.findId('flat-shadow-tree').cloneNode(true));
}
}
diff --git a/sky/examples/htmlish/framework/element.sky b/sky/examples/htmlish/framework/element.sky
index d2c1d1c..9df9c0d 100644
--- a/sky/examples/htmlish/framework/element.sky
+++ b/sky/examples/htmlish/framework/element.sky
@@ -22,10 +22,10 @@
module.exports.Element = sky.registerElement(
class extends Element {
static get tagName() { return 'element'; }
- constructor (module) {
- super();
+ constructor (hostModule) {
+ super(hostModule);
this.state = 'loading';
- this.module = module;
+ this.module = hostModule;
this.definedPrototype = sky.Element;
}
setPrototype(prototype) {
@@ -44,8 +44,8 @@
}
let tagName = this.getAttribute('name');
let constructorName = tagName.charAt(0).toUpperCase() + tagName.slice(1) + 'Element';
- let constructor = function (module) {
- super(module);
+ let constructor = function (hostModule) {
+ super(hostModule);
if (this.init)
this.init();
if (style)
diff --git a/sky/examples/radio.sky b/sky/examples/radio.sky
index 02c1f6a..3da67a0 100644
--- a/sky/examples/radio.sky
+++ b/sky/examples/radio.sky
@@ -13,8 +13,8 @@
class extends Element {
static get tagName() { return 'radio'; }
static get shadow() { return true; }
- constructor (module) {
- super(module);
+ constructor (hostModule) {
+ super(hostModule);
this.addEventListener('click', (event) => this.checked = true);
this.shadowRoot.append(module.document.findId('radio-shadow').content.cloneNode(true));
}
@@ -53,8 +53,8 @@
class extends Element {
static get tagName() { return 'radiogroup'; }
static get shadow() { return true; }
- constructor (module) {
- super(module);
+ constructor (hostModule) {
+ super(hostModule);
this.shadowRoot.append(module.document.findId('radiogroup-shadow').content.cloneNode(true));
}
get value () {
diff --git a/sky/specs/modules.md b/sky/specs/modules.md
index 7cdf70d..4a83f4d 100644
--- a/sky/specs/modules.md
+++ b/sky/specs/modules.md
@@ -56,11 +56,11 @@
Object prototype = Element;
}
interface InternalElementConstructorWithoutShadow {
- constructor (Module module);
+ constructor (Module hostModule);
attribute String tagName;
}
interface InternalElementConstructorWithShadow {
- constructor (Module module);
+ constructor (Module hostModule);
attribute String tagName;
attribute Boolean shadow;
}
@@ -69,7 +69,7 @@
InternalElementConstructorWithShadow);
abstract class AbstractModule : EventTarget {
- readonly attribute Document document; // O(1) // the Documentof the module or application
+ readonly attribute Document document; // O(1) // the Document of the module or application
Promise<any> import(String url); // O(Yikes) // returns the module's exports
private Array<Module> getImports(); O(N) // returns the Module objects of all the imported modules
@@ -90,16 +90,21 @@
// defaults to Element).
// - let shadow be option's shadow property's value coerced to a
// boolean, if the property is present, or else the value false.
- // - let shadow be option's tagName property's value.
- // - create a new Function that:
- // - throws if not called as a constructor
- // - creates an actual element object (the C++-backed object)
- // - initialises the shadow tree if shadow on the options is
- // true
- // - calls constructor, if it's not null, with the module as
- // the argument
- // - is marked as created by registerElement() so that it can
- // be recognised if used as an argument to registerElement()
+ // - let tagName be option's tagName property's value.
+ // - create a new Function that acts as if it had the signature of
+ // the constructors in the ElementConstructor interface, and that
+ // runs the follows steps when called:
+ // - throw if not called as a constructor
+ // - create an actual element object (the C++-backed object)
+ // called tagName, along with the specified attributes
+ // - initialise the shadow tree if shadow is true
+ // - call constructor, if it's not null, with the module
+ // within which the new element is being constructed as the
+ // argument
+ // - append all the specified children
+ // - mark that new Function as created by registerElement() so that
+ // it can be recognised if used as an argument to
+ // registerElement()
// - let that new Function's prototype be the aforementioned prototype
// - let that new Function have tagName and shadow properties set to
// the aforementioned tagName and shadow
diff --git a/sky/specs/runloop.md b/sky/specs/runloop.md
index 20231fc..25b0c78 100644
--- a/sky/specs/runloop.md
+++ b/sky/specs/runloop.md
@@ -31,7 +31,7 @@
7. Run pending tasks until the 8.333ms expires. Each task may only run
for at most 1ms, after 1ms they get a (catchable) EDeadlineExceeded
exception. While there are no pending tasks, sleep.
- Tasks are thingsl like:
+ Tasks are things like:
- timers
- updating the DOM in response to parsing
- input events
@@ -39,3 +39,6 @@
TODO(ianh): Update the timings above to have some relationship to
reality.
+
+TODO(ianh): Define how scroll notifications get sent, or decide to
+drop them entirely from this model.