Re: [w3c/webcomponents] Update HTML Modules Proposed Spec changes and initial proposal document (#793)

annevk commented on this pull request.



>      - b\. If *url* is failure, then:
       - i\. Let *error* be a new TypeError exception.
-      - ii\. Set *htmlModule’s* *parse error* to *error*.
-      - iii\. Return *htmlModule*.  Note: This step is essentially validating all of the requested module specifiers. We treat a module with unresolvable module specifiers the same as one that cannot be parsed; in both cases, a syntactic issue makes it impossible to ever contemplate instantiating the module later.
-  - 8\.   Set *htmlModule’s* *record* to *result*.
-  - 9\.   Return *htmlModule*.
-- Define ParseHTMLModule(*source*, *realm*, *htmlModule*) as roughly the following.  TODO Given that we define  HTML Module Record in ES6, should this function be defined over there?  We’re using the HTML5 parser though...
-  - 1\. Let *record* be a new HTML Module record that this algorithm will subsequently initialize. 
-  - 2\. Run the HTML5 parser on source to obtain the result *document*.
-  - 3\. Set *record*.[[HostDefined]] = *htmlModule*.
-  - 4\. For each HTMLScriptElement *script* in *document*:
-    - a\. Let *se* be a new ScriptEntry record (see definition in ES6 changes above).
+      - ii\. Set *htmlModuleScript*'s *parse error* to *error*.
+      - iii\. Return *htmlModuleScript*.  Note: This step is essentially validating all of the requested module specifiers. We treat a module with unresolvable module specifiers the same as one that cannot be parsed; in both cases, a syntactic issue makes it impossible to ever contemplate instantiating the module later.
+  - 8\. Set *htmlModuleScript*'s *record* to *result*.
+  - 9\. Return *htmlModuleScript*.
+- Introduce a new algorithm ParseHTMLModule(*source*, *realm*, *htmlModuleScript*) as the following.

I think this needs to be more detailed. In particular what I think we want to do is to run the parser in a mode similar to XMLHttpRequest, whereby nothing is executed or fetched. And then once done we walk the resulting tree and execute scripts provided they meet the requirements.

It also seems reasonable to me to not require the `type` attribute as this is a different processing model so we can also offer developer conveniences.

> -  - 5\. Return *record*.
-- Change fetch a [single module script](https://html.spec.whatwg.org/#fetch-a-single-module-script) as follows:
-  - In step 9, allow HTML MIME type through in addition to JavaScript.
-  - In step 11, don’t unconditionally [create a module script](https://html.spec.whatwg.org/#fetching-scripts:creating-a-module-script).  Instead, key off the MIME type extracted in step 9, creating an HTML Module instead if we have an HTML MIME type.
-- Change step 5 of [fetch the descendants of a module script](https://html.spec.whatwg.org/#fetch-the-descendants-of-a-module-script) such that when record is an HTML Module, use [[SourceName]] from each *record*.[[RequestedModules]] instead of the Source Text Module Record field *record*.[[RequestedModules]].  This change basically just accounts for the differences in how Source Text Module Record and HTML Module Record store their descendant module URLs.
+      - i\. Set *se*[[InlineModuleRecord]] = null
+      - ii\. Set *se*[[ExternalScriptURL]] = *script’s* src URL
+    - d\. Append *se* to *scriptEntries*.
+  - 4\. Return a new HTML Module Record { [[Realm]]: *realm*, [[Environment]]: *undefined*, [[Namespace]]: *undefined*, [[Status]]: `"uninstantiated"`, [[EvaluationError]]: *undefined*, [[HostDefined]]: *htmlModuleScript*, [[RequestedModules]]: *scriptEntries*, [[DFSIndex]]: *undefined*, [[DFSAncestorIndex]]: *undefined* }.
+- Provide an implementation of the abstract operation HostGetDefaultExport(*module*) as the following:
+  1. Assert: *module* is an HTML Module.  Note: It is anticipated that in the future this may be expanded to support other module types (JSON etc).
+  1. Let *htmlModuleScript* be *module*.[[HostDefined]].
+  1. Let *document* be *htmlModuleScript*'s *document*.
+  1. Return *document*.
+- Change [fetch a single module script](https://html.spec.whatwg.org/#fetch-a-single-module-script) as follows:
+  - In step 9, allow `text/html` type through in addition to JavaScript.

As per #742 I object to this.

-- 
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/w3c/webcomponents/pull/793#pullrequestreview-203633805

Received on Thursday, 14 February 2019 09:16:21 UTC