You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+12-1
Original file line number
Diff line number
Diff line change
@@ -421,6 +421,17 @@ It is often useful for implementation classes to inherit from each other, if the
421
421
422
422
However, it is not required! The wrapper classes will have a correct inheritance chain, regardless of the implementation class inheritance chain. Just make sure that, either via inheritance or manual implementation, you implement all of the expected operations and attributes.
423
423
424
+
### The `[LegacyFactoryFunction]` extended attribute
425
+
426
+
For interfaces which have the `[LegacyFactoryFunction]` extended attribute, the implementation class file must contain the `legacyFactoryFunction` export, with the signature `(thisValue, globalObject, [...legacyFactoryFunctionArgs], { newTarget, wrapper })`, which is used for:
427
+
428
+
- Setting up initial state that will always be used, such as caches or default values
429
+
-`thisValue` holds the value of a new uninitialized implementation instance, which may be ignored by returning a different object, similarly to how constructors with overridden return values are implemented.
430
+
- Keep a reference to the relevant `globalObject` for later consumption.
431
+
- Processing constructor arguments `legacyFactoryFunctionArgs` passed to the legacy factory function constructor, if the legacy factory function takes arguments.
432
+
-`newTarget` holds a reference to the value of `new.target` that the legacy factor function was invoked with.
433
+
-`wrapper` holds a reference to the uninitialized wrapper instance, just like in `privateData` with the standard impl constructor.
434
+
424
435
### The init export
425
436
426
437
In addition to the `implementation` export, for interfaces, your implementation class file can contain an `init` export. This would be a function taking as an argument an instance of the implementation class, and is called when any wrapper/implementation pairs are constructed (such as by the exports of the [generated wrapper module](https://github.com/jsdom/webidl2js#for-interfaces)). In particular, it is called even if they are constructed by [`new()`](newglobalobject), which does not invoke the implementation class constructor.
@@ -484,6 +495,7 @@ webidl2js is implementing an ever-growing subset of the Web IDL specification. S
484
495
-`[Clamp]`
485
496
-`[EnforceRange]`
486
497
-`[Exposed]`
498
+
-`[LegacyFactoryFunction]`
487
499
-`[LegacyLenientThis]`
488
500
-`[LegacyLenientSetter]`
489
501
-`[LegacyNoInterfaceObject]`
@@ -510,7 +522,6 @@ Notable missing features include:
510
522
-`[AllowShared]`
511
523
-`[Default]` (for `toJSON()` operations)
512
524
-`[Global]`'s various consequences, including the named properties object and `[[SetPrototypeOf]]`
0 commit comments