RESOLVED FIXED 23300
Selection functions should throw exceptions when used on buttons
https://bugs.webkit.org/show_bug.cgi?id=23300
Summary Selection functions should throw exceptions when used on buttons
Mads Ager
Reported 2009-01-13 12:39:54 PST
Firefox throws exceptions when using selection functions on HTMLInputElements that do not support selection. Maybe WebKit should to? Patch on its way.
Attachments
Patch (7.19 KB, patch)
2009-01-13 12:44 PST, Mads Ager
no flags
Updated to throw exceptions in selectionStart and selectionEnd setters (8.11 KB, patch)
2009-01-15 12:33 PST, Mads Ager
darin: review+
Mads Ager
Comment 1 2009-01-13 12:44:10 PST
Sam Weinig
Comment 2 2009-01-13 12:52:28 PST
Are there any known sites that require this?
Mads Ager
Comment 3 2009-01-13 13:11:51 PST
(In reply to comment #2) > Are there any known sites that require this? Not that I know of, no. As far as I can tell, we have tried to be compatible with Firefox here. The selection-function test seemed to pass on Firefox but only because it throws exceptions along the way. I like the fact that this gets rid of the custom getOwnPropertySlot implementation. Come to think of it, that custom implementation will get in the way of changes to setSelectionRange on buttons: HTMLInputElement.prototype.setSelectionRange = function(){}; var b = document.getElementById("button"); b.setSelectionRange; // <--- undefined Also, returning undefined will probably lead to exceptions throw in the code anyway since people will most likely try to call the function or use the value of the attributes?
Sam Weinig
Comment 4 2009-01-13 14:15:57 PST
What does IE do? I am always hesitant to throw exceptions as they can often break un-expecting scripts.
Mads Ager
Comment 5 2009-01-13 23:13:51 PST
IE does not support the selection attributes and functions on HTMLInputElements. Therefore, I think that Firefox compatibility should be the goal for these functions.
Darin Adler
Comment 6 2009-01-15 08:24:17 PST
This takes care of the getter for selectionStart, for selectionEnd, and the function setSelectionRange. What about the setters for selectionStart and selectionEnd? Is it appropriate for them to silently do nothing, or should they be throwing exceptions too?
Mads Ager
Comment 7 2009-01-15 12:11:26 PST
Good point, thanks! The setters should be throwing exceptions as well. I'll upload an updated patch ASAP.
Mads Ager
Comment 8 2009-01-15 12:33:26 PST
Created attachment 26768 [details] Updated to throw exceptions in selectionStart and selectionEnd setters
Mads Ager
Comment 9 2009-01-22 22:55:42 PST
Darin and Sam, could one of you guys have a look at this again? Thanks.
Darin Adler
Comment 10 2009-01-26 19:38:40 PST
Comment on attachment 26768 [details] Updated to throw exceptions in selectionStart and selectionEnd setters r=me
Dimitri Glazkov (Google)
Comment 11 2009-01-27 09:24:55 PST
Note You need to log in before you can comment on or make changes to this bug.