Skip to content

Commit

Permalink
fixup! Implement [LegacyFactoryFunction]
Browse files Browse the repository at this point in the history
  • Loading branch information
ExE-Boss committed Apr 29, 2020
1 parent ee7f6ef commit f8a21b8
Show file tree
Hide file tree
Showing 3 changed files with 176 additions and 166 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,7 @@ Creates a new instance of the wrapper class and corresponding implementation cla

This is useful inside implementation class files, where it is easiest to only deal with impls, not wrappers.

#### `new(globalObject [ , newTarget ])`
#### `new(globalObject, newTarget)`

Creates a new instance of the wrapper class and corresponding implementation class, but without invoking the implementation class constructor logic. Then returns the implementation class.

Expand Down
6 changes: 3 additions & 3 deletions lib/constructs/interface.js
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ class LegacyFactoryFunction {
// the return type, which is used by HTML's element legacy factory functions:
str += `
const thisArgument = exports.new(globalObject, new.target);
const result = Impl.legacyFactoryFunction.call(thisArg, ${formatArgs(setupArgs)});
const result = Impl.legacyFactoryFunction.call(thisArgument, ${formatArgs(setupArgs)});
return utils.tryWrapperForImpl(utils.isObject(result) ? result : thisArgument);
`;

Expand Down Expand Up @@ -1206,7 +1206,7 @@ class Interface {

generateIface() {
this.str += `
function makeWrapper(globalObject, newTarget = undefined) {
function makeWrapper(globalObject, newTarget) {
if (globalObject[ctorRegistrySymbol] === undefined) {
throw new Error('Internal error: invalid global object');
}
Expand Down Expand Up @@ -1292,7 +1292,7 @@ class Interface {
return wrapper;
};
exports.new = (globalObject, newTarget = undefined) => {
exports.new = (globalObject, newTarget) => {
${this.isLegacyPlatformObj ? "let" : "const"} wrapper = makeWrapper(globalObject, newTarget);
exports._internalSetup(wrapper, globalObject);
Expand Down
Loading

0 comments on commit f8a21b8

Please sign in to comment.