Page MenuHomePhabricator

jquery.placeholder: Polyfill implementation should not affect .val() and submission
Closed, ResolvedPublic

Description

jquery.placeholder is applied to all input elements with a placeholder class.

In IE, this causes .val() to return the placeholder string when it's supposed to be empty. It causes bug 47039 in Translate and may cause other issues.

As an experiment, I tried replacing the core jquery.placeholder.js with the
plugin of the same name from here:
https://github.com/mathiasbynens/jquery-placeholder

Everything just worked, including the placeholder in the search box.

Of course, it needs more testing, and the whole thing may also have some other solution.


Version: 1.19
Severity: normal
See Also:
https://bugzilla.wikimedia.org/show_bug.cgi?id=47039

Details

Reference
bz47057

Event Timeline

bzimport raised the priority of this task from to Normal.
bzimport set Reference to bz47057.
bzimport added a subscriber: Unknown Object (MLST).
Amire80 created this task.Apr 9 2013, 8:51 PM

Rephrasing summary, there is nothing "built-in" about jquery.placeholder.

(In reply to comment #0)

jquery.placeholder is applied to all input elements with a placeholder class.

Attribute, not class. <input placeholder="xx"> not <input class="placeholder">

Changed the relationship with bug 47039 from depends on to see, as we're implementing a work-around.

Is this a duplicate of bug 40430?

(In reply to comment #3)

Is this a duplicate of bug 40430?

I don't think so.

(In reply to comment #0)

As an experiment, I tried replacing the core jquery.placeholder.js with the
plugin of the same name from here:
https://github.com/mathiasbynens/jquery-placeholder

This could be a good idea (less of our own code = better), but that
scripts seems to be missing two bits of functionality:

  • Calling it as $(…).placeholder('Placeholder text') to set placeholder (its .placeholder function doesn't accept any arguments).
  • Support for inserting values into inputs with placeholders defined – dragging text or rightclick-pasting it could result in new value being appended to the placeholder or inserted in the middle of it.

If its maintainer wants to implement it, we could probably swap our
version for it like you suggested.

Change 95748 had a related patch set (by Bartosz Dziewoński) published:
Relicense jquery.placeholder.js to MIT

https://gerrit.wikimedia.org/r/95748

Change 95748 merged by jenkins-bot:
Relicense jquery.placeholder.js to MIT

https://gerrit.wikimedia.org/r/95748

So I've had our jquery.placeholder relicensed to MIT (same as the library linked by Amir in comment 0) and filed a parent bug about merging them (bug 57179). Doing that (or just porting the relevant part) will fix this bug.

Now with I1ecca3d8 merged this should work. I'd appreciate if you could verify, Amir :)

Amir: Could you please answer comment 9?

Meh, I'll just mark it as fixed.