This is an archived snapshot of W3C's public bugzilla bug tracker, decommissioned in April 2019. Please see the home page for more details.

Bug 12299 - The (normative and non-normative) assertion that tokenlist.item(index) / tokenlist[index] returns null for index>=length appears to be in conflict with WebIDL, at least for the index property case; afaict WebIDL requires that index property getters throw
Summary: The (normative and non-normative) assertion that tokenlist.item(index) / toke...
Status: RESOLVED FIXED
Alias: None
Product: HTML WG
Classification: Unclassified
Component: LC1 HTML5 spec (show other bugs)
Version: unspecified
Hardware: Other other
: P3 normal
Target Milestone: ---
Assignee: Ian 'Hixie' Hickson
QA Contact: HTML WG Bugzilla archive list
URL: http://www.whatwg.org/specs/web-apps/...
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-03-14 10:26 UTC by contributor
Modified: 2011-08-04 05:13 UTC (History)
8 users (show)

See Also:


Attachments

Description contributor 2011-03-14 10:26:53 UTC
Specification: http://www.whatwg.org/specs/web-apps/current-work/multipage/urls.html
Section: http://www.whatwg.org/specs/web-apps/current-work/#domtokenlist-0

Comment:
The (normative and non-normative) assertion that tokenlist.item(index) /
tokenlist[index] returns null for index>=length appears to be in conflict with
WebIDL, at least for the index property case; afaict WebIDL requires that
index property getters throw Type Error for out or range values. It may be
possible per WebIDL to have .index and the index property getters do different
things, but that doesn't seem like super-useful behaviour. Possibly we should
throw in all cases.

Posted from: 88.131.66.80
User agent: Mozilla/5.0 (X11; Linux x86_64; rv:2.0b13pre) Gecko/20110308 Firefox/4.0b13pre
Comment 1 James Graham 2011-03-14 10:32:21 UTC
Actually I think I might be wrong on what WebIDL requires; since corresponding properties for indexes outside the range are never created, trying to access such properties it will return undefined except in strict mode. Nevertheless the specs are inconsistent here.
Comment 2 Boris Zbarsky 2011-03-14 12:28:50 UTC
[index] needs to return undefined when out of range.

.item(index) can do whatever it wants to.

That's how nodelists already behave: .item() returns null, while [index] returns undefined.
Comment 3 Ms2ger 2011-03-14 12:49:17 UTC
NodeLists can change too...
Comment 4 Boris Zbarsky 2011-03-14 13:27:29 UTC
Can they?  No sites depending on the current behavior?

Throwing for out-of-bounds access on nodelist, btw, is _definitely_ not web-compatible.  Dunno about token list.
Comment 5 James Graham 2011-03-14 13:48:57 UTC
Right, I think the spec is *confusing* but I no longer think it is wrong except for the non-normative text which is very misleading about how out-of-bounds index access will work.

I don't think it is worth trying to change the null/undefined thing; given the subtlety of their distinction, any solution will feel wrong, so we may as well just go for what is already implemented.
Comment 6 Ms2ger 2011-03-14 18:49:40 UTC
Hmm, I was thinking of .item() returning undefined, but that might be hard to spec too.
Comment 7 Boris Zbarsky 2011-03-14 18:54:03 UTC
Also impossible in some language bindings, right?
Comment 8 Cameron McCormack 2011-03-14 21:18:09 UTC
Yep.  I think it is fine to leave item() return null where [n] would be undefined because the property doesn't exist.
Comment 9 Ian 'Hixie' Hickson 2011-05-06 19:48:28 UTC
James, can you clarify what is confusing so that I can clear it up? I'm not 100% sure how to improve this.
Comment 10 Ian 'Hixie' Hickson 2011-05-09 08:32:00 UTC
spoke to jgraham; this is about the domintro text specifically. we should make sure it doesn't imply that [index] access works like .item() access for out-of-range values.
Comment 11 contributor 2011-06-14 21:56:22 UTC
Checked in as WHATWG revision r6223.
Check-in comment: Simplify the non-normative descriptions of index getters to avoid confusing readers (the specifics of edge cases are rather subtle).
http://html5.org/tools/web-apps-tracker?from=6222&to=6223
Comment 12 Ian 'Hixie' Hickson 2011-06-14 22:03:14 UTC
EDITOR'S RESPONSE: This is an Editor's Response to your comment. If you are satisfied with this response, please change the state of this bug to CLOSED. If you have additional information and would like the editor to reconsider, please reopen this bug. If you would like to escalate the issue to the full HTML Working Group, please add the TrackerRequest keyword to this bug, and suggest title and text for the tracker issue; or you may create a tracker issue yourself, if you are able to do so. For more details, see this document:
   http://dev.w3.org/html5/decision-policy/decision-policy.html

Status: Accepted
Change Description: see diff given above
Rationale: Concurred with reporter's comments on IRC.
Comment 13 Ms2ger 2011-06-16 09:17:55 UTC
Updated DOM Core accordingly.

http://dvcs.w3.org/hg/domcore/rev/9ef55e2543bd
Comment 14 Michael[tm] Smith 2011-08-04 05:13:38 UTC
mass-move component to LC1