Skip to content

Commit f28c8e8

Browse files
committed
Fix #227: Make createEvent("touchevent") sometimes throw
Browsers typically disable touch events on non-touch devices, and there exists Web content that detects this difference using createEvent.
1 parent 4b291d1 commit f28c8e8

File tree

2 files changed

+26
-3
lines changed

2 files changed

+26
-3
lines changed

dom.bs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4982,6 +4982,13 @@ invoked, must run these steps:
49824982
<tr><td>"<code>wheelevent</code>"<td>{{WheelEvent}}<td>[[!UIEVENTS]]
49834983
</table>
49844984

4985+
<li>
4986+
If the user agent does not support the <var>constructor</var> interface, or has it disabled
4987+
in its current configuration, let <var>constructor</var> be null.
4988+
4989+
<p class=note>Typically user agents have the {{TouchEvent}} interface disabled in some
4990+
configurations.
4991+
49854992
<li>If <var>constructor</var> is null, <a>throw</a> a
49864993
{{NotSupportedError}}.
49874994

dom.html

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2875,6 +2875,11 @@ <h3 class="heading settled" data-level="4.5" id="interface-document"><span class
28752875
<td><code class="idl"><a data-link-type="idl">WheelEvent</a></code>
28762876
<td><a data-link-type="biblio" href="#biblio-uievents">[UIEVENTS]</a>
28772877
</table>
2878+
<li>
2879+
If the user agent does not support the <var>constructor</var> interface, or has it disabled
2880+
in its current configuration, let <var>constructor</var> be null.
2881+
<p class="note" role="note">Typically user agents have the <code class="idl"><a data-link-type="idl" href="https://www.w3.org/TR/touch-events/#touchevent-interface">TouchEvent</a></code> interface disabled in some
2882+
configurations. </p>
28782883
<li>If <var>constructor</var> is null, <a data-link-type="dfn" href="https://heycam.github.io/webidl/#dfn-throw">throw</a> a <code class="idl"><a data-link-type="idl" href="https://heycam.github.io/webidl/#notsupportederror">NotSupportedError</a></code>.
28792884
<li>Let <var>event</var> be the result of <a data-link-type="dfn" href="#concept-event-constructor">invoking</a> the initial
28802885
value of <var>constructor</var> with the empty string as argument.
@@ -3172,7 +3177,7 @@ <h3 class="heading settled" data-level="4.9" id="interface-element"><span class=
31723177
<p>Set <var>result</var> to <a data-link-type="abstract-op" href="https://tc39.github.io/ecma262/#sec-construct">Construct</a>(<var>C</var>). Rethrow any
31733178
exceptions. </p>
31743179
<li>
3175-
<p>If <var>result</var> does not implement the <code class="idl"><a data-link-type="idl" href="https://html.spec.whatwg.org/multipage/dom.html#htmlelement">HTMLElement</a></code> interface, <a data-link-type="dfn" href="https://heycam.github.io/webidl/#dfn-throw">throw</a> a <code class="idl"><a data-link-type="idl" href="https://tc39.github.io/ecma262/#sec-native-error-types-used-in-this-standard-typeerror">TypeError</a></code> exception. </p>
3180+
<p>If <var>result</var> does not implement the <code class="idl"><a data-link-type="idl" href="https://html.spec.whatwg.org/multipage/dom.html#htmlelement">HTMLElement</a></code> interface, <a data-link-type="dfn" href="https://heycam.github.io/webidl/#dfn-throw">throw</a> a <code class="idl"><a data-link-type="idl">TypeError</a></code> exception. </p>
31763181
<p class="note" role="note">This is meant to be a brand check to ensure that the object was allocated by the <code class="idl"><a data-link-type="idl" href="https://html.spec.whatwg.org/multipage/dom.html#htmlelement">HTMLElement</a></code> constructor. See <a href="https://github.com/heycam/webidl/issues/97">webidl #97</a> about making this more
31773182
precise. </p>
31783183
<li>
@@ -4918,7 +4923,7 @@ <h3 class="heading settled" data-level="8.1" id="dom-events-changes"><span class
49184923
</ul>
49194924
<h3 class="heading settled" data-level="8.2" id="dom-core-changes"><span class="secno">8.2. </span><span class="content">DOM Core</span><a class="self-link" href="#dom-core-changes"></a></h3>
49204925
<p>These are the changes made to the features described in <cite>DOM Level 3 Core</cite>.</p>
4921-
<p><code class="idl"><a data-link-type="idl" href="https://heycam.github.io/webidl/#idl-DOMString">DOMString</a></code>, <code class="idl"><a data-link-type="idl" href="https://heycam.github.io/webidl/#dfn-domexception">DOMException</a></code>, and <code class="idl"><a data-link-type="idl" href="https://heycam.github.io/webidl/#common-domtimestamp">DOMTimeStamp</a></code> are now defined in Web IDL.</p>
4926+
<p><code class="idl"><a data-link-type="idl" href="https://heycam.github.io/webidl/#idl-DOMString">DOMString</a></code>, <code class="idl"><a data-link-type="idl" href="https://heycam.github.io/webidl/#dfn-DOMException">DOMException</a></code>, and <code class="idl"><a data-link-type="idl" href="https://heycam.github.io/webidl/#common-domtimestamp">DOMTimeStamp</a></code> are now defined in Web IDL.</p>
49224927
<p><code class="idl"><a data-link-type="idl" href="#node">Node</a></code> now inherits from <code class="idl"><a data-link-type="idl" href="#eventtarget">EventTarget</a></code>.</p>
49234928
<p><a data-link-type="dfn" href="#concept-node">Nodes</a> are implicitly <a data-link-type="dfn" href="#concept-node-adopt">adopted</a> across <a data-link-type="dfn" href="#concept-document">document</a> boundaries.</p>
49244929
<p><a data-link-type="dfn" href="#concept-doctype">Doctypes</a> now always have a <a data-link-type="dfn" href="#concept-node-document">node document</a> and can be moved
@@ -6008,7 +6013,6 @@ <h3 class="no-num no-ref heading settled" id="index-defined-elsewhere"><span cla
60086013
<a data-link-type="biblio">[ECMASCRIPT]</a> defines the following terms:
60096014
<ul>
60106015
<li><a href="https://tc39.github.io/ecma262/#sec-construct">Construct</a>
6011-
<li><a href="https://tc39.github.io/ecma262/#sec-native-error-types-used-in-this-standard-typeerror">TypeError</a>
60126016
</ul>
60136017
<li>
60146018
<a data-link-type="biblio">[css-animations-1]</a> defines the following terms:
@@ -6078,7 +6082,19 @@ <h3 class="no-num no-ref heading settled" id="index-defined-elsewhere"><span cla
60786082
<li>
60796083
<a data-link-type="biblio">[WEBIDL]</a> defines the following terms:
60806084
<ul>
6085+
<li><a href="https://heycam.github.io/webidl/#dfn-DOMException">DOMException</a>
60816086
<li><a href="https://heycam.github.io/webidl/#idl-DOMString">DOMString</a>
6087+
<li><a href="https://heycam.github.io/webidl/#hierarchyrequesterror">HierarchyRequestError</a>
6088+
<li><a href="https://heycam.github.io/webidl/#inuseattributeerror">InUseAttributeError</a>
6089+
<li><a href="https://heycam.github.io/webidl/#indexsizeerror">IndexSizeError</a>
6090+
<li><a href="https://heycam.github.io/webidl/#invalidcharactererror">InvalidCharacterError</a>
6091+
<li><a href="https://heycam.github.io/webidl/#invalidnodetypeerror">InvalidNodeTypeError</a>
6092+
<li><a href="https://heycam.github.io/webidl/#invalidstateerror">InvalidStateError</a>
6093+
<li><a href="https://heycam.github.io/webidl/#namespaceerror">NamespaceError</a>
6094+
<li><a href="https://heycam.github.io/webidl/#notfounderror">NotFoundError</a>
6095+
<li><a href="https://heycam.github.io/webidl/#notsupportederror">NotSupportedError</a>
6096+
<li><a href="https://heycam.github.io/webidl/#syntaxerror">SyntaxError</a>
6097+
<li><a href="https://heycam.github.io/webidl/#wrongdocumenterror">WrongDocumentError</a>
60826098
</ul>
60836099
</ul>
60846100
<h2 class="no-num no-ref heading settled" id="references"><span class="content">References</span><a class="self-link" href="#references"></a></h2>

0 commit comments

Comments
 (0)