DOMStringList.item() must return null for an invalid index. Sample Test: test(function () { var testEl = makeEl('div',{}); assert_equals( testEl.properties.names.item(0), null, 'item(0)' ); assert_equals( testEl.properties.names.item(-1), null, 'item(-1)' ); }, 'names.item() must return null for out of range indexes'); Expected: testEl.properties.names.item(-1) should return null Actual: INDEX_SIZE_ERR: DOM Exception 1: Index or size was negative, or greater than the allowed value According to the spec http://www.w3.org/TR/DOM-Level-3-Core/core.html#DOMStringList item() must return DOMString, The DOMString at the indexth position in the DOMStringList, or null if that is not a valid index. Currently it throws "INDEX_SIZE_ERR: DOM Exception 1: Index or size was negative, or greater than the allowed value", when index is negative.
Created attachment 166236 [details] Patch
Comment on attachment 166236 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=166236&action=review The implementation looks good. I am just concerned about cross-browser compatibility. > Source/WebCore/ChangeLog:8 > + DOMStringList.item() must return null for an invalid index. What is the behavior of other browsers (IE, Firefox, Opera)?
(In reply to comment #2) > (From update of attachment 166236 [details]) > View in context: https://bugs.webkit.org/attachment.cgi?id=166236&action=review > > The implementation looks good. I am just concerned about cross-browser compatibility. > > > Source/WebCore/ChangeLog:8 > > + DOMStringList.item() must return null for an invalid index. > > What is the behavior of other browsers (IE, Firefox, Opera)? I tested in Opera and Firefox. Both return null in case of negative index. Unable to test it in as I don't have access to IE.
Comment on attachment 166236 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=166236&action=review >>> Source/WebCore/ChangeLog:8 >>> + DOMStringList.item() must return null for an invalid index. >> >> What is the behavior of other browsers (IE, Firefox, Opera)? > > I tested in Opera and Firefox. Both return null in case of negative index. Unable to test it in as I don't have access to IE. Thanks for the clarification. Given that the spec also requires it, the change looks reasonable.
Comment on attachment 166236 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=166236&action=review >>>> Source/WebCore/ChangeLog:8 >>>> + DOMStringList.item() must return null for an invalid index. >>> >>> What is the behavior of other browsers (IE, Firefox, Opera)? >> >> I tested in Opera and Firefox. Both return null in case of negative index. Unable to test it in as I don't have access to IE. > > Thanks for the clarification. Given that the spec also requires it, the change looks reasonable. It would be better to describe other browsers' behaviors in the ChangeLog.
(In reply to comment #5) > (From update of attachment 166236 [details]) > View in context: https://bugs.webkit.org/attachment.cgi?id=166236&action=review > > >>>> Source/WebCore/ChangeLog:8 > >>>> + DOMStringList.item() must return null for an invalid index. > >>> > >>> What is the behavior of other browsers (IE, Firefox, Opera)? > >> > >> I tested in Opera and Firefox. Both return null in case of negative index. Unable to test it in as I don't have access to IE. > > > > Thanks for the clarification. Given that the spec also requires it, the change looks reasonable. > > It would be better to describe other browsers' behaviors in the ChangeLog. Sure I will update the Change log with other browsers behavior. Thanks for the review.
Committed r130026: <http://trac.webkit.org/changeset/130026>