Bug 149576 - [ES6] Add ScriptElement::determineScriptType
Summary: [ES6] Add ScriptElement::determineScriptType
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: New Bugs (show other bugs)
Version: WebKit Nightly Build
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Yusuke Suzuki
URL:
Keywords:
Depends on:
Blocks: 148897
  Show dependency treegraph
 
Reported: 2015-09-25 16:01 PDT by Yusuke Suzuki
Modified: 2016-08-05 23:29 PDT (History)
11 users (show)

See Also:


Attachments
Patch (5.14 KB, patch)
2015-09-25 16:04 PDT, Yusuke Suzuki
no flags Details | Formatted Diff | Diff
Patch (3.08 KB, patch)
2015-09-26 01:01 PDT, Yusuke Suzuki
no flags Details | Formatted Diff | Diff
Patch (3.53 KB, patch)
2016-08-05 01:53 PDT, Yusuke Suzuki
no flags Details | Formatted Diff | Diff
Patch (3.54 KB, patch)
2016-08-05 02:07 PDT, Yusuke Suzuki
no flags Details | Formatted Diff | Diff
Patch (5.07 KB, patch)
2016-08-05 02:25 PDT, Yusuke Suzuki
no flags Details | Formatted Diff | Diff
Patch (4.93 KB, patch)
2016-08-05 02:37 PDT, Yusuke Suzuki
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Yusuke Suzuki 2015-09-25 16:01:05 PDT
[ES6] Add isModuleType function to ScriptElements
Comment 1 Yusuke Suzuki 2015-09-25 16:04:21 PDT
Created attachment 261951 [details]
Patch
Comment 2 Ryosuke Niwa 2015-09-25 23:52:55 PDT
Comment on attachment 261951 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=261951&action=review

> Source/WebCore/dom/ScriptElement.cpp:165
> +    else if (type == "module")

Where is this type value specified?  I can't find any mentioning of the "module" type in
https://html.spec.whatwg.org/multipage/scripting.html#attr-script-type
or
https://html.spec.whatwg.org/multipage/infrastructure.html#valid-mime-type

Also, shouldn't this check for the type of the element given SVGScriptElement doesn't support modules?

> Source/WebCore/html/HTMLScriptElement.cpp:171
> +bool HTMLScriptElement::isModuleType() const
> +{
> +#if ENABLE(ES6_MODULES)
> +    return fastGetAttribute(typeAttr).string() == "module";
> +#else
> +    return false;
> +#endif
> +}

I think it's better to put this in ScriptElement so that checks for "module" type appears next to each other.
Comment 3 Yusuke Suzuki 2015-09-26 00:42:22 PDT
Comment on attachment 261951 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=261951&action=review

Thank you for your comment!

>> Source/WebCore/dom/ScriptElement.cpp:165
>> +    else if (type == "module")
> 
> Where is this type value specified?  I can't find any mentioning of the "module" type in
> https://html.spec.whatwg.org/multipage/scripting.html#attr-script-type
> or
> https://html.spec.whatwg.org/multipage/infrastructure.html#valid-mime-type
> 
> Also, shouldn't this check for the type of the element given SVGScriptElement doesn't support modules?

This is why the module tag is behind the compile time flag.
Currently, there is consensus, but not specified yet.

https://github.com/whatwg/loader/blob/master/roadmap.md#stage-0-basic-static-loading
https://github.com/whatwg/loader/issues/83#issuecomment-143219400
https://github.com/dherman/module-tag/blob/master/explainer.md
https://esdiscuss.org/topic/any-news-about-the-module-element

And oops, I've missed it. After thinking about it, I think enabling "module" for svg script element seems more consistent.
So, I'll drop the SVGScriptElement's change. Put all "module" related changes into ScriptElement.

>> Source/WebCore/html/HTMLScriptElement.cpp:171
>> +}
> 
> I think it's better to put this in ScriptElement so that checks for "module" type appears next to each other.

Looks very nice to me.
Comment 4 Yusuke Suzuki 2015-09-26 01:01:20 PDT
Created attachment 261966 [details]
Patch
Comment 5 Ryosuke Niwa 2015-09-26 01:13:19 PDT
Okay, why don't we wait until those discussion settle?  We can implement the other parts of the module loading without this, right?  e.g. @import inside a script element.
Comment 6 Yusuke Suzuki 2015-09-26 01:21:41 PDT
(In reply to comment #5)
> Okay, why don't we wait until those discussion settle?  We can implement the
> other parts of the module loading without this, right?  e.g. @import inside
> a script element.

Pending this patch is OK to me :-)
I'll do the other parts first, like https://bugs.webkit.org/show_bug.cgi?id=149574.
Comment 7 Yusuke Suzuki 2016-08-05 00:05:40 PDT
Let's reboot this.
The description about type="module" is explicitly specified in the whatwg living standard!

https://html.spec.whatwg.org/multipage/webappapis.html#integration-with-the-javascript-module-system
Comment 8 Yusuke Suzuki 2016-08-05 01:53:40 PDT
Created attachment 285410 [details]
Patch
Comment 9 Yusuke Suzuki 2016-08-05 02:07:18 PDT
Created attachment 285412 [details]
Patch
Comment 10 Yusuke Suzuki 2016-08-05 02:25:17 PDT
Created attachment 285413 [details]
Patch
Comment 11 Yusuke Suzuki 2016-08-05 02:37:15 PDT
Created attachment 285415 [details]
Patch
Comment 12 Saam Barati 2016-08-05 11:47:47 PDT
Comment on attachment 285415 [details]
Patch

LGTM but I'll let other WebCore reviewers give the official review
Comment 13 Yusuke Suzuki 2016-08-05 23:09:03 PDT
Comment on attachment 285415 [details]
Patch

Thanks!
Comment 14 WebKit Commit Bot 2016-08-05 23:29:47 PDT
Comment on attachment 285415 [details]
Patch

Clearing flags on attachment: 285415

Committed r204221: <http://trac.webkit.org/changeset/204221>
Comment 15 WebKit Commit Bot 2016-08-05 23:29:55 PDT
All reviewed patches have been landed.  Closing bug.