RESOLVED FIXED 42814
maxLength should not be applied to non-text types
https://bugs.webkit.org/show_bug.cgi?id=42814
Summary maxLength should not be applied to non-text types
Kent Tamura
Reported 2010-07-22 03:38:57 PDT
maxLength should not be applied to non-text types
Attachments
Patch (11.02 KB, patch)
2010-07-22 03:46 PDT, Kent Tamura
no flags
Kent Tamura
Comment 1 2010-07-22 03:40:49 PDT
According to http://www.whatwg.org/specs/web-apps/current-work/multipage/the-input-element.html#input-type-attr-summary , maxLength should be applied only to text, search, url, tel, email, and password types.
Kent Tamura
Comment 2 2010-07-22 03:46:56 PDT
Darin Adler
Comment 3 2010-07-22 07:31:20 PDT
Comment on attachment 62283 [details] Patch > +var input = document.createElement('input'); > +input.maxLength = 2; > +input.type = 'number'; > +document.body.appendChild(input); > +input.focus(); > +document.execCommand('insertText', false, '1234'); > +shouldBe('input.value', '"1234"'); Once you've set up the basics like this, it would be better to have the test cover many cases. It's good to go past the minimum and make sure you've covered all the code. Ideally you have a test that will fail if you change anything in your patch, rather than a test that covers just the most important thing you've changed. It's unfortunate that HTMLInputElement itself calls a virtual function for supportsMaxLength. It's true that it needs to be virtual so that InputElement can call it, but when HTMLInputElement is calling itself the extra cost is not justified. There is a programming technique that eliminates this without any special care at call sites. See Node::localName, Node::virtualLocalName, Element::localName and Element::virtualLocalName, for an example of the technique. Using the technique would make our compiled code smaller and faster, but would make the code a bit more ugly. Something from the existing code, not new: It seems a little bit unfortunate that when invoking the regular expression engine you can't tell it that you want to match against the entire string. It ends up doing work you don't need. We could consider adding a new operation to RegularExpression. Otherwise things look good.
Kent Tamura
Comment 4 2010-07-22 19:32:43 PDT
(In reply to comment #3) > Once you've set up the basics like this, it would be better to have the test cover many cases. It's good to go past the minimum and make sure you've covered all the code. Ideally you have a test that will fail if you change anything in your patch, rather than a test that covers just the most important thing you've changed. I think the existing tests (not only the new one) cover this change well. > It's unfortunate that HTMLInputElement itself calls a virtual function for supportsMaxLength. It's true that it needs to be virtual so that InputElement can call it, but when HTMLInputElement is calling itself the extra cost is not justified. There is a programming technique that eliminates this without any special care at call sites. See Node::localName, Node::virtualLocalName, Element::localName and Element::virtualLocalName, for an example of the technique. Using the technique would make our compiled code smaller and faster, but would make the code a bit more ugly. Ok, I changed supportsMaxLength() call in HTMLInputElement to isTextType() and a comment. Committed as r63942.
Note You need to log in before you can comment on or make changes to this bug.