MooTool's String.prototype.contains conflicts with ES6 #2402

Closed
benjaminp opened this Issue Aug 10, 2012 · 11 comments

Projects

None yet

8 participants

@benjaminp

ES6 adds the String.prototype.contains method (specified here; look at the PDF). As you can see, it does not have the same behavior as MooTools' String.prototype.contains. Namely, the second parameter in ES6 is a position to start searching from not a separator. Firefox 17 implements the ES6 version, which is breaking sites that use MooTools.

@arian
MooTools member

Only MooTools 1.2 breaks. MooTools >= 1.3 overwrites .contains because it's not in this list: https://github.com/mootools/mootools-core/blob/c7a161d85/Source/Core/Core.js#L266-268

That said, we probably should prepare for those new methods and make our API compatible in 1.4.6 and 1.5.

@gutworth what's the current status? As far as I know it's only a proposal, but now it's implemented it probably won't change a lot, will it?
Also, what other new methods can we expect, I saw the string extras, Array.from/Array.of, and some number methods right?

@benjaminp

There are more methods on the Number constructor: Number.isFinite(), Number.isInteger(), Number.isNaN(), Number.toInteger().

Technically, everything is subject to change until the spec is finalized. However, the new methods in Firefox are based on the harmony proposals page, which is supposed to mean the committee has reached consensus even if it's not formally speced yet.

@sebmarkbage
MooTools member

There is some chance there might be Object.extend and more as well.

@BenoitZugmeyer

Note for completeness: Mozilla care about this issue and apparently will do some evangelism in order to prevent websites using MooTools 1.2 to break when Firefox 17 will be released.

See comment https://bugzilla.mozilla.org/show_bug.cgi?id=784280#c10

@arian
MooTools member

That's great to hear. I do think we should change String.prototype.contains to match the signature with ES6 though in 1.5.

@DavidBruant

I've added a section on MDN to describe this issue. Please tell me if I've made a mistake.

I agree it would make sense for MooTools to match ES6 signature. However, the feature isn't exactly the same, namely on the second parameter.
So, one thing that would ease the transition from MooTools 1.2 to 1.5 would be to provide an alias for the current String.prototype.contains (maybe to String.prototype.legacyContains or String.prototype.oldContains). This way, people using the old version will just have to rename their calls and not the logic around it.

@sebmarkbage
MooTools member

We did end up changing method signature for bind and had a tutorial for upgrading: https://github.com/mootools/mootools-core/wiki/Update-from-1.2-to-1.3
We already had a suitable alternative.

There was some projects that couldn't update to 1.3 for a long time, for various reasons (most notably Joomla). So there was also a minor revision update 1.2.5. For whatever reason that version only fixed bind specifically. Not the real issue. It wasn't until 1.3 all native methods were overridden. Maybe there needs to be a 1.2.6 release to allow for a quick fix.

@arian arian added a commit to arian/mootools-core that referenced this issue Oct 27, 2012
@kentaromiura kentaromiura Fixes #2402 - String.prototype.contains is now implemented according …
…to the new ES6 standard

- Moved the old String.prototype.contains implementation in 1.4compat
- Using good old indexOf at other places
f9307e0
@arian arian added a commit to arian/mootools-core that referenced this issue Dec 1, 2012
@arian arian Merge branch 'standard-contains' fixes #2402 c596b60
@kentaromiura kentaromiura added a commit that closed this issue Dec 1, 2012
@kentaromiura kentaromiura Fixes #2402 - String.prototype.contains is now implemented according …
…to the new ES6 standard

- Moved the old String.prototype.contains implementation in 1.4compat
- Using good old indexOf at other places
f9307e0
@arian arian reopened this Dec 10, 2012
@arian
MooTools member

Needs a fix for MooTools 1.2.6, as it probably breaks some selectors ($$) too: https://groups.google.com/forum/#!topic/mootools-users/W7MHwTFHYQ4

@Enyby

Quick fix: You need add "String.prototype.contains = undefined;" before init mootools core. Or add this row as first row in your core file.
Note: You need check other js code for using String.prototype.contains in default way. But this function implement only in firefox, than its usage unlikely.

@bartwomey bartwomey referenced this issue in mui/mochaui Jan 11, 2013
Closed

Total failure under Firefox 18 #137

@arian arian added a commit to arian/mootools-core that referenced this issue Jan 15, 2013
@arian arian Fixes #2402 for 1.2. Overwrite String.prototype.contains with the Moo…
…Tools version.

Firefox 18 implements .contains, and ES6 might do that as well. That breaks
some stuff, so we have to make sure it's overwritten with the 'correct'
MooTools version.
e3718bc
@arian arian added a commit to arian/mootools-core that referenced this issue Jan 15, 2013
@arian arian Fixes #2402 for 1.2. Overwrite String contains with the MooTools vers…
…ion.

Firefox 18 implements .contains, and ES6 might do that as well. That breaks
some stuff, so we have to make sure it's overwritten with the 'correct'
MooTools version.
7057039
@cdumez cdumez referenced this issue in qbittorrent/qBittorrent Jan 26, 2013
Closed

Web UI does not open with Firefox 18.0 #324

@hnuecke

Danke! Die Zeile in mootools core einzufügen war auch für mich (2.9.5) die Lösung

@arian
MooTools member

Okay, this problem is solved for 1.2 now too, and released, so we can close this! http://mootools.net/blog/2013/02/19/mootools-1-2-6-released/

@arian arian closed this Feb 19, 2013
@ibolmo ibolmo added a commit to ibolmo/mootools-core that referenced this issue Feb 16, 2014
@ibolmo ibolmo Fixes #2402 - String.prototype.contains is now implemented according …
…to the new ES6 standard

- Moved the old String.prototype.contains implementation in 1.4compat
- Using good old indexOf at other places
ef8a2b4
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment