Opened 11 years ago

Closed 11 years ago

Last modified 11 years ago

#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)

10480.patch (1.6 KB) - added by Maxime Handfield Lapointe 11 years ago.
Patch to solve the issue

Download all attachments as: .zip

Change History (5)

Changed 11 years ago by Maxime Handfield Lapointe

Attachment: 10480.patch added

Patch to solve the issue

comment:1 Changed 11 years ago by Maxime Handfield Lapointe

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 11 years ago by Piotr Jasiun

Resolution: duplicate
Status: newclosed

comment:3 Changed 11 years ago by Piotr Jasiun

This is duplicate of http://dev.ckeditor.com/ticket/7876 Generally val() function will be rewritten using valHooks.

comment:4 Changed 11 years ago by Jakub Ś

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).

Note: See TracTickets for help on using tickets.
© 2003 – 2022, CKSource sp. z o.o. sp.k. All rights reserved. | Terms of use | Privacy policy