Skip to content

Parameter reassigned before arguments #5939

@harai

Description

@harai

Uglify version (uglifyjs -V)

uglify-js 3.19.3

JavaScript input

((e) => {
  const t = e.pushState,
    r = e.replaceState;
  (e.pushState = function (r) {
    const n = new CustomEvent("pushstate", { state: r });
    return window.dispatchEvent(n), t.apply(e, arguments);
  }),
    (e.replaceState = function (t) {
      const n = new CustomEvent("replacestate", { state: t });
      return window.dispatchEvent(n), r.apply(e, arguments);
    }),
    (window.wcNavigation.historyPatched = !0);
})(window.history);

The uglifyjs CLI command executed or minify() options used.

$ uglifyjs work/test.js --compress annotations=false,arguments=false,arrows=false,assignments=false,awaits=false,booleans=false,collapse_vars=false,comparisons=false,conditionals=false,dead_code=false,default_values=false,directives=false,evaluate=false,functions=false,hoist_exports=false,hoist_props=false,if_return=false,imports=false,inline=false,join_vars=false,loops=false,merge_vars=true,negate_iife=false,objects=false,properties=false,pure_getters=false,reduce_funcs=false,reduce_vars=true,rests=false,sequences=false,side_effects=false,spreads=false,strings=false,switches=false,templates=false,typeofs=false,unused=true,varify=true,yields=false --keep-fnames -b --output work/test.min.js

Disable most compress options and enable merge_vars, reduce_vars, unused, and varify.

JavaScript output or error produced.

(e => {
    let t = e.pushState, r = e.replaceState;
    e.pushState = function(r) {
        r = new CustomEvent("pushstate", {
            state: r
        });
        return window.dispatchEvent(r), t.apply(e, arguments);
    }, e.replaceState = function(t) {
        t = new CustomEvent("replacestate", {
            state: t
        });
        return window.dispatchEvent(t), r.apply(e, arguments);
    }, window.wcNavigation.historyPatched = !0;
})(window.history);

t is reassigned just before getting its value with arguments keyword, which results in Error: Failed to execute 'replaceState' on 'History': CustomEvent object could not be cloned. error.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions