Bug 161651

Summary: [WebCore] Clean up script loading code in XML
Product: WebKit Reporter: Yusuke Suzuki <ysuzuki>
Component: XMLAssignee: Yusuke Suzuki <ysuzuki>
Status: RESOLVED FIXED    
Severity: Normal CC: cdumez, commit-queue, darin, dbates, esprehn+autocc, gyuyoung.kim, kangil.han, rniwa, sam
Priority: P2    
Version: WebKit Nightly Build   
Hardware: Unspecified   
OS: Unspecified   
Bug Depends on:    
Bug Blocks: 147340    
Attachments:
Description Flags
Patch
none
Patch rniwa: review+

Description Yusuke Suzuki 2016-09-06 15:41:23 PDT
...
Comment 1 Yusuke Suzuki 2016-11-16 20:12:09 PST
Created attachment 295022 [details]
Patch

WIP
Comment 2 Yusuke Suzuki 2016-11-16 22:06:35 PST
Created attachment 295028 [details]
Patch
Comment 3 Ryosuke Niwa 2016-11-16 22:21:50 PST
Comment on attachment 295028 [details]
Patch

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

> Source/WebCore/dom/ScriptElement.cpp:167
> +    // XHTML document does not support "defer" attribute semantics.
> +    // And module tag also uses defer attribute semantics. We disable script type="module" for non HTML document.

Is this behavior spec compliant!?
Comment 4 Yusuke Suzuki 2016-11-16 22:32:36 PST
Comment on attachment 295028 [details]
Patch

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

>> Source/WebCore/dom/ScriptElement.cpp:167
>> +    // And module tag also uses defer attribute semantics. We disable script type="module" for non HTML document.
> 
> Is this behavior spec compliant!?

XHTML defines "defer" attribute. But WebKit does not implement it for a long time.
Once "defer" is implemented, we can reconsider enabling modules in XHTML. But I'm not sure that's worth doing (implementing defer semantics and enabling modules in XHTML).

Since "defer" semantics is not implemented, before this patch, we just ignore the modules in XHTML document. But it causes some strange behavior.
For example, if you write <script type="module"> in document, it is ignored. But if you create script tag with `type="module"` dynamically, it works.
To make it consistent, I think disabling modules until "defer" is implemented in XHTML is better.

I'll note the above description in this comment.
Comment 5 Yusuke Suzuki 2016-11-16 22:38:30 PST
Comment on attachment 295028 [details]
Patch

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

>>> Source/WebCore/dom/ScriptElement.cpp:167
>>> +    // And module tag also uses defer attribute semantics. We disable script type="module" for non HTML document.
>> 
>> Is this behavior spec compliant!?
> 
> XHTML defines "defer" attribute. But WebKit does not implement it for a long time.
> Once "defer" is implemented, we can reconsider enabling modules in XHTML. But I'm not sure that's worth doing (implementing defer semantics and enabling modules in XHTML).
> 
> Since "defer" semantics is not implemented, before this patch, we just ignore the modules in XHTML document. But it causes some strange behavior.
> For example, if you write <script type="module"> in document, it is ignored. But if you create script tag with `type="module"` dynamically, it works.
> To make it consistent, I think disabling modules until "defer" is implemented in XHTML is better.
> 
> I'll note the above description in this comment.

We have a bug for that https://bugs.webkit.org/show_bug.cgi?id=123387. I'll paste this URL.
According to that bug, blink intentionally does not support it https://bugs.chromium.org/p/chromium/issues/detail?id=611136.
Comment 6 Yusuke Suzuki 2016-11-16 22:47:38 PST
Committed r208840: <http://trac.webkit.org/changeset/208840>