plone / plone.patternslib

An add-on to make patternslib patterns available within Plone 5.
https://pypi.org/project/plone.patternslib/
GNU General Public License v2.0
2 stars 5 forks source link

Only override startsWith and endWith if those are not present #26

Closed kcleong closed 6 years ago

kcleong commented 6 years ago

The startsWith and endWith methods are overridden/prototyped by default in jquery-ext.js. When these methods are already available in the browser these methods should not be overridden.

Maybe the protoTypes should be removed altogether? Most (if not all) modern browsers now support these methods. It also seems the implementation is not correct. For example startsWith can also accept a 2th argument for position (see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/startsWith).

I stumbled upon these methods when a custom javascript app refused to run, because of these prototyped methods. When I disabled the override, the app ran just fine.

screen shot 2018-03-27 at 15 12 38
pilz commented 6 years ago

Yes, good point. This compatibility code is rather old and I don't know the reason why it is there in the first place. But your workaround looks very sensible. I'll also backport that to patternslib. Thank you!