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 10640 - Allow for non-nullable objects
Summary: Allow for non-nullable objects
Status: RESOLVED FIXED
Alias: None
Product: HTML WG
Classification: Unclassified
Component: LC1 HTML5 spec (show other bugs)
Version: unspecified
Hardware: PC All
: P2 normal
Target Milestone: ---
Assignee: Ian 'Hixie' Hickson
QA Contact: HTML WG Bugzilla archive list
URL:
Whiteboard:
Keywords:
: 12724 (view as bug list)
Depends on:
Blocks:
 
Reported: 2010-09-16 07:57 UTC by Anne
Modified: 2011-08-13 07:51 UTC (History)
7 users (show)

See Also:


Attachments
patch for Web Apps 1.0 (104.43 KB, patch)
2011-06-07 02:42 UTC, Cameron McCormack
Details

Description Anne 2010-09-16 07:57:21 UTC
For various DOM Core methods it would be nice if method arguments could be annotated with "cannot be null" or some such and when annotated as such the binding would describe a language-specific exception to be thrown. I will use [NoNull] for now.
Comment 1 Darin Adler 2010-09-16 15:29:30 UTC
Maybe the sense should be reversed. Annotate when a null value is allowed.
Comment 2 Anne 2010-09-16 15:33:14 UTC
That could work too. For DOMString (and boolean, etc.) we have DOMString? to indicate it can also be null. Maybe this should just apply to everything instead of just primitives.
Comment 3 Cameron McCormack 2011-03-14 02:47:18 UTC
I think this is a good idea, and using the same "nullable" syntax seems sensible.  So:

  interface Node {
    // Can't pass in null, and null will never be returned.
    Node appendChild(in Node newChild);

    // parentNode can be null.
    readonly attribute Node? parentNode;

    ...
  };

This change likely affects everyone using Web IDL, though, so I'll leave some time for objections first.
Comment 5 Ian 'Hixie' Hickson 2011-05-23 21:02:16 UTC
I'm really not looking forward to having to change all six quintillion occurrences of this in the IDLs in Web Apps 1.0. Any chance we could change this to Object! rather than Object?, with the meaning "null not allowed"?
Comment 6 Cameron McCormack 2011-05-23 21:34:46 UTC
I would have expected there to be fewer instances of "?" to add than "!".  If you don't have time, I can run through the spec to verify this, and give you a diff if you want.
Comment 7 Ian 'Hixie' Hickson 2011-06-02 01:19:38 UTC
http://krijnhoetmer.nl/irc-logs/whatwg/20110602#l-119
Comment 8 Cameron McCormack 2011-06-03 04:19:43 UTC
Going through the Web Applications spec today, I find around 1000 instances of types that could be made nullable and around 350 instances where you would need to do so, or only around 80 if you don't count the "Function"s for event listener attributes.  I therefore think it makes sense to do this, rather than invert the meaning and use "!" to exclude null.  I will work on a patch for this.
Comment 9 Cameron McCormack 2011-06-07 02:42:22 UTC
Created attachment 996 [details]
patch for Web Apps 1.0

This adds "?" where appropriate in the IDL fragments in the Web Apps 1.0 spec and removes a few prose requirements checking for null where the null would not get through the Web IDL requirements in the first place.
Comment 10 Cameron McCormack 2011-06-07 02:43:40 UTC
Back to Ian.
Comment 11 Ian 'Hixie' Hickson 2011-06-13 23:39:09 UTC
Dude you are the _king_.

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 below (and above! thanks heycam!)
Rationale: Concurred with reporter's comments.
Comment 12 contributor 2011-06-13 23:39:40 UTC
Checked in as WHATWG revision r6220.
Check-in comment: Update IDL to recent WebIDL changes, thanks to heycam.
http://html5.org/tools/web-apps-tracker?from=6219&to=6220
Comment 13 Michael[tm] Smith 2011-08-04 05:01:42 UTC
mass-moved component to LC1
Comment 14 Ms2ger 2011-08-13 07:51:07 UTC
*** Bug 12724 has been marked as a duplicate of this bug. ***