-
-
Notifications
You must be signed in to change notification settings - Fork 216
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
fix: [1706] Handle non string values gracefully for removeAttribute o… #1707
fix: [1706] Handle non string values gracefully for removeAttribute o… #1707
Conversation
b49fdea
to
b87aba3
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice contribution!
@@ -793,6 +793,9 @@ export default class Element | |||
* @param name Name. | |||
*/ | |||
public removeAttribute(name: string): void { | |||
if (typeof name !== 'string') { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The attribute is actually not ignored when name is not a string, it is stringified.
You can test it with this:
var div = document.createElement('div');
div.setAttribute(null, 'test');
// Outputs '<div null="test"></div>'
console.log(div.outerHTML);
div.removeAttribute(null);
// Outputs '<div></div>'
console.log(div.outerHTML);
I think it is best if we add the stringify using String()
to NamedNodeMap
to methods such as getNamedItem()
.
b87aba3
to
c5bd563
Compare
…m:OlaviSau/happy-dom into fix-1706-remove-attribute-with-non-string
7936d65
to
38934ea
Compare
One note - there is no need to implement a check on NamedNodeMap setNamedItem because |
4e7e662
to
5e41a11
Compare
This is quite a significant breaking change even though it's more correct this way. Perhaps we should add a strict mode flag and not enable it by default and have a transition period? |
1f99c55
to
3422c7e
Compare
3422c7e
to
9f67980
Compare
…n elements