From ecd6dd6406e4f7404498a3eca9756075c2869de5 Mon Sep 17 00:00:00 2001 From: Domenic Denicola Date: Tue, 24 May 2016 15:24:40 +0200 Subject: [PATCH] Make selection{Start,End,Direction} no longer throw when non-applicable This keeps up with a recent spec change: https://github.com/whatwg/html/pull/1006. --- lib/jsdom/living/nodes/HTMLInputElement-impl.js | 6 +++--- lib/jsdom/living/nodes/HTMLInputElement.idl | 6 +++--- lib/jsdom/living/nodes/HTMLTextAreaElement.idl | 6 +++--- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/lib/jsdom/living/nodes/HTMLInputElement-impl.js b/lib/jsdom/living/nodes/HTMLInputElement-impl.js index 59810a9013..20200769f3 100644 --- a/lib/jsdom/living/nodes/HTMLInputElement-impl.js +++ b/lib/jsdom/living/nodes/HTMLInputElement-impl.js @@ -231,7 +231,7 @@ class HTMLInputElementImpl extends HTMLElementImpl { get selectionStart() { if (!allowVariableLengthSelection(this.type)) { - throw new DOMException(DOMException.INVALID_STATE_ERR); + return null; } return this._selectionStart; @@ -247,7 +247,7 @@ class HTMLInputElementImpl extends HTMLElementImpl { get selectionEnd() { if (!allowVariableLengthSelection(this.type)) { - throw new DOMException(DOMException.INVALID_STATE_ERR); + return null; } return this._selectionEnd; @@ -263,7 +263,7 @@ class HTMLInputElementImpl extends HTMLElementImpl { get selectionDirection() { if (!allowVariableLengthSelection(this.type)) { - throw new DOMException(DOMException.INVALID_STATE_ERR); + return null; } return this._selectionDirection; diff --git a/lib/jsdom/living/nodes/HTMLInputElement.idl b/lib/jsdom/living/nodes/HTMLInputElement.idl index 22496550a2..7e421b694c 100644 --- a/lib/jsdom/living/nodes/HTMLInputElement.idl +++ b/lib/jsdom/living/nodes/HTMLInputElement.idl @@ -53,9 +53,9 @@ interface HTMLInputElement : HTMLElement { // [SameObject] readonly attribute NodeList labels; void select(); - attribute unsigned long selectionStart; - attribute unsigned long selectionEnd; - attribute DOMString selectionDirection; + attribute unsigned long? selectionStart; + attribute unsigned long? selectionEnd; + attribute DOMString? selectionDirection; void setRangeText(DOMString replacement); void setRangeText(DOMString replacement, unsigned long start, unsigned long end, optional SelectionMode selectionMode = "preserve"); void setSelectionRange(unsigned long start, unsigned long end, optional DOMString direction); diff --git a/lib/jsdom/living/nodes/HTMLTextAreaElement.idl b/lib/jsdom/living/nodes/HTMLTextAreaElement.idl index ad14095a56..462c64ca35 100644 --- a/lib/jsdom/living/nodes/HTMLTextAreaElement.idl +++ b/lib/jsdom/living/nodes/HTMLTextAreaElement.idl @@ -30,9 +30,9 @@ interface HTMLTextAreaElement : HTMLElement { // [SameObject] readonly attribute NodeList labels; void select(); - attribute unsigned long selectionStart; - attribute unsigned long selectionEnd; - attribute DOMString selectionDirection; + attribute unsigned long? selectionStart; + attribute unsigned long? selectionEnd; + attribute DOMString? selectionDirection; void setRangeText(DOMString replacement); void setRangeText(DOMString replacement, unsigned long start, unsigned long end, optional SelectionMode selectionMode = "preserve"); void setSelectionRange(unsigned long start, unsigned long end, optional DOMString direction);