<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<!DOCTYPE bugzilla SYSTEM "https://www.w3.org/Bugs/Public/page.cgi?id=bugzilla.dtd">

<bugzilla version="5.0.4"
          urlbase="https://www.w3.org/Bugs/Public/"
          
          maintainer="sysbot+bugzilla@w3.org"
>

    <bug>
          <bug_id>25114</bug_id>
          
          <creation_ts>2014-03-21 09:15:35 +0000</creation_ts>
          <short_desc>Why throw instead of no-op when open=&quot;&quot; is absent?</short_desc>
          <delta_ts>2016-08-18 14:48:52 +0000</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>1</classification_id>
          <classification>Unclassified</classification>
          <product>WHATWG</product>
          <component>HTML</component>
          <version>unspecified</version>
          <rep_platform>Other</rep_platform>
          <op_sys>other</op_sys>
          <bug_status>RESOLVED</bug_status>
          <resolution>FIXED</resolution>
          
          
          <bug_file_loc>http://www.whatwg.org/specs/web-apps/current-work/#close-the-dialog</bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords></keywords>
          <priority>P3</priority>
          <bug_severity>normal</bug_severity>
          <target_milestone>Unsorted</target_milestone>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter>contributor</reporter>
          <assigned_to name="Ian &apos;Hixie&apos; Hickson">ian</assigned_to>
          <cc>annevk</cc>
    
    <cc>ian</cc>
    
    <cc>jonas</cc>
    
    <cc>mathias</cc>
    
    <cc>mike</cc>
    
    <cc>zcorpan</cc>
          
          <qa_contact>contributor</qa_contact>

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>102735</commentid>
    <comment_count>0</comment_count>
    <who name="">contributor</who>
    <bug_when>2014-03-21 09:15:35 +0000</bug_when>
    <thetext>Specification: http://www.whatwg.org/specs/web-apps/current-work/multipage/commands.html
Multipage: http://www.whatwg.org/C#close-the-dialog
Complete: http://www.whatwg.org/c#close-the-dialog
Referrer: http://www.whatwg.org/specs/web-apps/current-work/multipage/

Comment:
Why throw instead of no-op when open=&quot;&quot; is absent?

Posted from: 90.230.218.37 by simonp@opera.com
User agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_9_2) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/33.0.1750.112 Safari/537.36 OPR/20.0.1387.51 (Edition Next)</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>104453</commentid>
    <comment_count>1</comment_count>
    <who name="Ian &apos;Hixie&apos; Hickson">ian</who>
    <bug_when>2014-04-25 17:44:59 +0000</bug_when>
    <thetext>Because if you call close() on a closed dialog, you almost certainly have a coding error, and throwing an exception lets you find out exactly where the error is with a stack trace.

But I could go either way. Should we change this?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>104525</commentid>
    <comment_count>2</comment_count>
    <who name="Simon Pieters">zcorpan</who>
    <bug_when>2014-04-28 06:17:35 +0000</bug_when>
    <thetext>I figured that since the user can close dialogs with &quot;escape&quot;, it could complicate things for the app developer and might result in cargo-cult always checking if the dialog is open before calling close() or using try/catch.

As for coding errors, would it also be a coding error to close a modal dialog that is not the top-most modal dialog?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>104594</commentid>
    <comment_count>3</comment_count>
    <who name="Ian &apos;Hixie&apos; Hickson">ian</who>
    <bug_when>2014-04-28 22:12:26 +0000</bug_when>
    <thetext>(In reply to Simon Pieters from comment #2)
&gt; I figured that since the user can close dialogs with &quot;escape&quot;, it could
&gt; complicate things for the app developer and might result in cargo-cult
&gt; always checking if the dialog is open before calling close() or using
&gt; try/catch.

Yeah, I could see this going either way.


&gt; As for coding errors, would it also be a coding error to close a modal
&gt; dialog that is not the top-most modal dialog?

Probably...


Anyone else have an opinion? If nobody has anything else to add, I&apos;ll probably go with zcorpan&apos;s suggestion.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>104666</commentid>
    <comment_count>4</comment_count>
    <who name="Simon Pieters">zcorpan</who>
    <bug_when>2014-04-29 09:22:58 +0000</bug_when>
    <thetext>Trying to gather more feedback here: https://twitter.com/zcorpan/status/461067952100741120</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>104668</commentid>
    <comment_count>5</comment_count>
    <who name="Mathias Bynens">mathias</who>
    <bug_when>2014-04-29 09:30:57 +0000</bug_when>
    <thetext>I agree with zcorpan. Not having `close()` throw greatly simplifies scripts.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>104678</commentid>
    <comment_count>6</comment_count>
    <who name="Anne">annevk</who>
    <bug_when>2014-04-29 13:15:47 +0000</bug_when>
    <thetext>This should not throw. Tasks/microtasks want to race on closing the dialog without try/catch. Same with exitFullscreen() and a dozen other APIs.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>104843</commentid>
    <comment_count>7</comment_count>
    <who name="">contributor</who>
    <bug_when>2014-04-30 18:44:16 +0000</bug_when>
    <thetext>Checked in as WHATWG revision r8591.
Check-in comment: dialog.close() shouldn&apos;t throw
http://html5.org/tools/web-apps-tracker?from=8590&amp;to=8591</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>127156</commentid>
    <comment_count>8</comment_count>
    <who name="Simon Pieters">zcorpan</who>
    <bug_when>2016-08-18 14:48:52 +0000</bug_when>
    <thetext>Chromium issue https://bugs.chromium.org/p/chromium/issues/detail?id=638943</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>