#10480 closed Bug (duplicate)
jQuery val() override behaves differently than the original
Reported by: | Maxime Handfield Lapointe | Owned by: | |
---|---|---|---|
Priority: | Normal | Milestone: | |
Component: | General | Version: | 4.1.2 |
Keywords: | HasPatch | Cc: |
Description
Summary: CKEditor's val() returns the value of the last element, while jQuery's returns the value of the first element.
Reproduce: On a page with 2 input text, do the following: jQuery('input[type=text]').first().val('value1') jQuery('input[type=text]').last().val('value2') jQuery('input[type=text]').val()
This last line will return 'value1' if on a page without CKEditor, and 'value2' on a page with CKEditor (and jqueryOverrideVal set to true).
This will happen in any browser and os. (Tested with chrome on Ubuntu)
More in depth: The val() function of jQuery, when used to get a value, will get the value of the first element it contains only.
The val() function of CKEditor that overrides jQuery's will walk over every element contained in the jQuery object (using each) and call getData or oldValMethod on each element. Then, it will return the value of the last element.
I do not have a test case file as this can be reproduced on just about any page, as long as the jqueryOverrideVal is set to true.
Attachments (1)
Change History (5)
Changed 12 years ago by
Attachment: | 10480.patch added |
---|
comment:1 Changed 12 years ago by
Forgot to hit preview... Sorry for bad formatting. These are the lines for reproducing:
jQuery('input[type=text]').first().val('value1') jQuery('input[type=text]').last().val('value2') jQuery('input[type=text]').val()
comment:2 Changed 12 years ago by
Resolution: | → duplicate |
---|---|
Status: | new → closed |
comment:3 Changed 12 years ago by
This is duplicate of http://dev.ckeditor.com/ticket/7876 Generally val() function will be rewritten using valHooks.
comment:4 Changed 12 years ago by
This is a duplicate of #7876 which is a part of larger issue #10281.
We are currently rewriting adapter and this issue is included.
Btw. You can always fork CKEditor 4 code from https://github.com/ckeditor/ckeditor-dev, prepare your fix and make a "pull request" (here is the example list of pull requests https://github.com/ckeditor/ckeditor-dev/pulls?direction=desc&page=1&sort=created&state=open). In comment please specify link to bug for which this fix was prepared. That way your proposed changes may be taken into account - perhaps they will give idea to one of our devs (but such pull request can also be closed).
Patch to solve the issue