Conversation
Adds support for the `{ type: 'text' }` import attribute,
which enables importing text content as a JavaScript string.
|
Looks good. I do wonder whether there ought to be a required MIME type, especially given that the other types all have one. If Alternatively there could be a requirement not to have certain MIME types, e.g. to disallow importing JavaScript as text. I think I am personally inclined not to impose such requirements, but I could see the argument either way. |
|
Would this make available the same content that is already available via |
|
Good question. Looks like For clarity it might be good to rename the destination to Anyway, yes, this ends up letting you get the exact same content as |
|
Do we actually want a |
|
|
|
It's specific in that we can ask the server for JSON with Given that the destination is exposed these days through |
|
Oh, nice, I didn't realize that it got exposed there and wasn't just editorial. In that case I agree |
|
The TC39 / ECMA-262 part of this proposal has now advanced to Stage 3. |
noamr
left a comment
There was a problem hiding this comment.
I think this needs to be rebased, and properly support modulepreload like CSS/JSON.
|
Do the tests cover module preload? The spec text seemed good AFAICT! |
noamr
left a comment
There was a problem hiding this comment.
Unofficial LGTM % tests for modulepreload
@noamr They do now (I just updated the WPT PR). |
annevk
left a comment
There was a problem hiding this comment.
This looks good to me. It would be great if @nicolo-ribaudo could also do a quick skim.
|
MDN and browser bugs should be completed for this as well before landing. |
Done. |
source
Outdated
| <li> | ||
| <p>Let <var>result</var> be <span>CreateTextModule</span>(<var>text</var>).</p> | ||
|
|
||
| <p>If this throws an exception, catch it, and set <var>script</var>'s <span |
There was a problem hiding this comment.
CreateTextModule never throws
| <p>A <span>module script</span> is a <dfn export>text module script</dfn> if its <span | ||
| data-x="concept-script-record">record</span> is a <span>Synthetic Module Record</span>, and it | ||
| was created via the <span data-x="creating a text module script">create a text module | ||
| script</span> algorithm. Text module scripts represent a text document.</p> |
There was a problem hiding this comment.
"text document" is already a different concept used in the spec (https://html.spec.whatwg.org/#read-text), which covers CSS/JSON/plain-text/WebVTT but not HTML/XML.
There was a problem hiding this comment.
Maybe just "plan textual data", if we want to write something? Or we could just remove this last sentence.
There was a problem hiding this comment.
Would this work? This would match what's in the TC39 proposal as well.
Or would "textual data document" be better?
| script</span> algorithm. Text module scripts represent a text document.</p> | |
| script</span> algorithm. Text module scripts represent textual data.</p> |
This is the HTML counterpart for the newly-introduced TC39 Import Text Stage 2 proposal; this has been previously discussed here in #9444, and is closely related (but not blocking on) PR #11657, which correspondingly adds byte imports.
The
type: 'text'import attribute is introduced here without any MIME type requirement, and without any validity or well-formedness checks on the returned string value. @sffc has raised some concerns about additional validation steps being desirable for text content, which would be appropriate for consideration in this spec, rather than the JS spec.The implementer support noted below is based on feedback from delegates at the 2025 November TC39 meeting.
/infrastructure.html ( diff )
/links.html ( diff )
/references.html ( diff )
/webappapis.html ( diff )