PATCH: Node.setAttribute incorrectly restricts 'value' to be only strings
Reported by nickg | March 15th, 2010 @ 07:05 PM | in 1.2.x
Looks like I have the magic touch today.
http://github.com/client9/env-js/commit/4cd9fa12fd7d1ea868429be605f...
The following:
somenode.setAttribute('foo', 0);
somenode.setAttribute('foo', null);
are valid constructs, and set the attribute to the string-value
of the argument. However they semi-silently get ignored right now.
I found this since numeric values are used in the Image constructor
and get passed to setAttribute
.
in src/dom/element.js
around line 49, we have:
// test for exceptions
if (__ownerDocument__(this).implementation.errorChecking) {
// throw Exception if Attribute is readonly
if (attr._readonly) {
throw(new DOMException(DOMException.NO_MODIFICATION_ALLOWED_ERR));
}
// throw Exception if the value string contains an illegal character
if (!__isValidString__(value)) {
throw(new DOMException(DOMException.INVALID_CHARACTER_ERR));
}
}
// assign values to properties (and aliases)
attr.value = value + '';
So at the end, we make sure value
is a string. But
right above, we do a isValidString check on the
raw value, not the string value. If a non-string is passed in, this
explodes.
setting value = value + '' uptop will solve this (committed).
This one is a blocker for me. Unit tests will be in forthcoming commit for Image.
Comments and changes to this ticket
-
Thatcher March 16th, 2010 @ 07:05 PM
- State changed from new to resolved
- Tag changed from setattribute to dom, element, setattribute
- Milestone set to 1.2.x
tagged as 1.2.0.9, here's to magic days
http://github.com/thatcher/env-js/commit/80ad06d53fcb1bdcbb8f42af0e...
Please Sign in or create a free account to add a new ticket.
With your very own profile, you can contribute to projects, track your activity, watch tickets, receive and update tickets through your email and much more.
Create your profile
Help contribute to this project by taking a few moments to create your personal profile. Create your profile ยป
a javascript browser environment