w3c / DOM-Parsing

DOM Parsing and Serialization
https://w3c.github.io/DOM-Parsing/
Other
27 stars 14 forks source link

Spec out normative text when parseFromString() is passed an unsupported MIME type #41

Closed dbates-wk closed 5 years ago

dbates-wk commented 5 years ago

Latest draft (12/11/2018) only has non-normative text for how parseFromString() behaves when passed an unsupported MIME type, highlighting for emphasis:

document = domparser . parseFromString ( str, type ) Parse str using a parser that matches type's supported MIME types (either XML or HTML), and return a Document object contained the parsed content if successful. If not successful, returns a Document describing the error. If type does not match a value in the SupportedType enumeration, an exception is thrown [WEBIDL].

But all this text is marked non-normative. And there is no equivalent normative/requirement text to the bolded sentence above. Please spec something normative.

The bolded sentence above doesn’t sound too crazy, but I haven’t surveyed what browsers do, yet.

dbates-wk commented 5 years ago

@travisleithead @hober @rniwa

dbates-wk commented 5 years ago

@annevk

rniwa commented 5 years ago

Do we have data as to what various browsers currently do?

annevk commented 5 years ago

This falls out from it being an enum. Web IDL describes enum handling.

dbates-wk commented 5 years ago

This falls out from it being an enum. Web IDL describes enum handling.

Can we please spec this in the normative text? Maybe just move/copy the:

If type does not match a value in the SupportedType enumeration, an exception is thrown [WEBIDL].

to the normative text section.

annevk commented 5 years ago

The normative text for enums is here: https://heycam.github.io/webidl/#es-enumeration. You cannot put it in the algorithm for the function, because at that point IDL validation has already happened by definition.

dbates-wk commented 5 years ago

The normative text for enums is here: https://heycam.github.io/webidl/#es-enumeration. You cannot put it in the algorithm for the function, because at that point IDL validation has already happened by definition.

I see. Is there anything that can be done here to improve the spec. language to make this more apparent?

Closing this issue since the normative equivalent text for throwing an exception for an unsupported MIME type falls out from https://heycam.github.io/webidl/#es-enumeration.

dbates-wk commented 5 years ago

Do we have data as to what various browsers currently do?

I haven't checked Edge, but Mac Chrome Canary Version 74.0.3686.0, Mac Firefox 64.0.2, Safari Version 12.0 (14606.1.36.1.2) seems to be unhappy and throw an exception when I tried to evaluate:

(new DOMParser).parseFromString("<h1>Hello</h1>", "text/HTML")

annevk commented 5 years ago

@dbates-wk I'm not sure, there's a lot of methods that accept enums where the specification doesn't really talk about it and leaves that to IDL. I guess in WebKit this isn't implemented in the IDL layer thus far and therefore it's more of a method-by-method thing to account for?