New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Allow String
objects as source
#329
Comments
I double checked and we are not talking about strings created using the var S = new String('hello'); Just for later reference:
After reading through the specs a bit more I have my doubts.
✔️
❓ What does "is provided to Javascript" mean? There seems to be some transition from values outside of javascript?
If I understand this correctly any API accepting DOMString in the spec should accept all the possible values listed in the I also checked what browsers are doing: Even the types typescript provides for the same API you reference only allow the primitive interface DOMParser {
parseFromString(str: string, type: SupportedType): Document;
} I must say that I personally prefer a more clearly typed API that only allows strings as input (explicitly stating when it allows With to goal to still allow users to use our lib as described in the spec, it could make sense to implement and expose a @piranna What do you think? |
Good analisys, it made me doubt and double check myself too :-)
I find this two quotes from the docs conflicting, since there's no
That's my interpretation. MDN documentation is confusing on this point, but seems that when a
Yes... but it's as simple as calling to
Yes, maybe... but seems it's how the spec dictates it must work (at least in Chrome):
My opinion is to stick to the spec and not add non-standard APIs or methods. That means:
|
I will have to think about it. |
As I said, the other alternative is to have it typed as |
At
xmldom/lib/dom-parser.js
Line 95 in 8116f56
source
is astring
literal, but the spec dictates is aDOMString
object, that in Javascript, it maps directly to the corresponding String class. So,String
objects, should be allowed, but instead they are directly rejected.Here we have two options, call to
.toString()
to all values provided in thesource
argument, or check thatsource
is astring
literal or aString
object.The text was updated successfully, but these errors were encountered: