Bug 149576

Summary: [ES6] Add ScriptElement::determineScriptType
Product: WebKit Reporter: Yusuke Suzuki <ysuzuki>
Component: New BugsAssignee: Yusuke Suzuki <ysuzuki>
Status: RESOLVED FIXED    
Severity: Normal CC: achristensen, ap, cdumez, commit-queue, darin, esprehn+autocc, ggaren, kangil.han, rniwa, saam, sam
Priority: P2    
Version: WebKit Nightly Build   
Hardware: Unspecified   
OS: Unspecified   
Bug Depends on:    
Bug Blocks: 148897    
Attachments:
Description Flags
Patch
none
Patch
none
Patch
none
Patch
none
Patch
none
Patch none

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.