plone / Products.CMFPlone

The core of the Plone content management system
https://plone.org
GNU General Public License v2.0
246 stars 186 forks source link

Javascript error in `jquery-ext.js` from patternslib #2674

Closed kcleong closed 1 year ago

kcleong commented 5 years ago

BUG/PROBLEM REPORT (OR OTHER COMMON ISSUE)

What I did:

Call startsWith javascript function with a special char (such as ?) on any plone site:

var example = 'spam bacon eggs spam';
console.log(example.startsWith('?'));

On plone.org in the Chrome developer toolbar:

screenshot 2018-12-21 at 12 28 10

When I click 'default.js' in above screenshot, I see:

screenshot 2018-12-21 at 12 29 11

What I expect to happen:

The startsWith function should not return an error. See this codepen where I reproduced the error: https://codepen.io/anon/pen/oJZBqz

What actually happened:

The startswith and endswith functions are overridden using prototype in:

https://github.com/plone/Products.CMFPlone/blob/master/Products/CMFPlone/static/components/patternslib/src/core/jquery-ext.js#L226-L227

A PR (see https://github.com/plone/plone.patternslib/pull/26) was merged in plone.patternslib to only override these methods if they are not present. Most modern browsers (if not all) have support for those methods.

What would be a good solution to fix this in Products.CMFPlone/static/components/patternslib/src/core/jquery-ext.js? I am not that familiar with these static resources, I think the easiest would be to replace the two offending lines with the fix from PR 26 in plone.patternslib. If I look at the commit history (see https://github.com/plone/plone.patternslib/commits/master/src/plone/patternslib/static/components/patternslib/src/core/jquery-ext.js) of jquery-ext.js, I see only two commits. There are not other changes in this file, expect for the first commit and the fix from the PR.

What version of Plone/ Addons I am using:

Plone 5.1.4

jensens commented 1 year ago

I close the issue, because it addresses a Plone version that is no longer supported. If you think this is wrong please reopen the issue and assign a matching milestone.