Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Refactor evented to make mincompatable with Chrome 53 #8810

Merged
merged 3 commits into from
Jul 22, 2024

Conversation

mister-ben
Copy link
Contributor

@mister-ben mister-ben commented Jul 21, 2024

Description

Chrome 53 doesn't like the minified output. Specifically, it throws Uncaught SyntaxError: Unexpected token ( on the ternary in the minified version of normalizeListenArgs()

const normalizeListenArgs = (self, args, fnName) => {
// If the number of arguments is less than 3, the target is always the
// evented object itself.
const isTargetingSelf = args.length < 3 || args[0] === self || args[0] === self.eventBusEl_;
let target;
let type;
let listener;
if (isTargetingSelf) {
target = self.eventBusEl_;
// Deal with cases where we got 3 arguments, but we are still listening to
// the evented object itself.
if (args.length >= 3) {
args.shift();
}
[type, listener] = args;
} else {
[target, type, listener] = args;
}
validateTarget(target, self, fnName);
validateEventType(type, self, fnName);
validateListener(listener, self, fnName);
listener = Fn.bind_(self, listener);
return {isTargetingSelf, target, type, listener};
};

Line breaks added for clarify

Tt = (e, t, s) => {
  var i = t.length < 3 || t[0] === e || t[0] === e.eventBusEl_;
  let r, n, a;
  return i ? (r = e.eventBusEl_, 3 <= t.length && t.shift(), [n, a] = t) : [r, n, a] = t, ft(r, e, s), yt(n, e, s), bt(a, e, s), a = _(e, a), {
    isTargetingSelf: I,
    target: r,
    type: n,
    listener: a
  }
},

Chrome would be happy with this if [r, n, a] = t were ([r, n, a] = t).

Specific Changes proposed

Refactor normalizeListenArgs() slightly to use multiple statements to coerce uglify-js to include parentheses.
Also updates uglify-js, but that in itself isn't the fix.

Fixes #8783

Requirements Checklist

  • Feature implemented / Bug fixed
  • If necessary, more likely in a feature request than a bug fix
    • Change has been verified in an actual browser - Browserstack Chrome 53
    • Unit Tests updated or fixed
    • Docs/guides updated
    • Example created (starter template on JSBin)
    • Has no DOM changes which impact accessiblilty or trigger warnings (e.g. Chrome issues tab)
    • Has no changes to JSDoc which cause npm run docs:api to error
  • Reviewed by Two Core Contributors

Copy link

codecov bot commented Jul 21, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 83.07%. Comparing base (e78bcc7) to head (106b84a).
Report is 2 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #8810   +/-   ##
=======================================
  Coverage   83.07%   83.07%           
=======================================
  Files         120      120           
  Lines        8022     8024    +2     
  Branches     1925     1925           
=======================================
+ Hits         6664     6666    +2     
  Misses       1358     1358           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@mister-ben mister-ben added the patch This PR can be added to a patch release. label Jul 22, 2024
src/js/mixins/evented.js Outdated Show resolved Hide resolved
Co-authored-by: Gary Katsevman <git@gkatsev.com>
@benoit74
Copy link

benoit74 commented Aug 9, 2024

Any chance to release this soon?

@mister-ben mister-ben deleted the fix-uglify branch August 9, 2024 07:53
@mister-ben
Copy link
Contributor Author

8.17.3 is available and contains the fix. It's not latest yet but will be soon.

@benoit74
Copy link

benoit74 commented Aug 9, 2024

Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
patch This PR can be added to a patch release.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Uncaught SyntaxError: Unexpected token ( and Uncaught ReferenceError: videojs is not defined in chrome v 53
3 participants