Skip to content

Commit e47f689

Browse files
committed
Better dispatch signature
1 parent 250ab7f commit e47f689

File tree

6 files changed

+9
-9
lines changed

6 files changed

+9
-9
lines changed

core.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

docs/core.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

docs/core.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

esm/script-handler.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ const execute = async (script, source, XWorker, isAsync) => {
6161
get: () => script,
6262
});
6363
module.registerJSModule(interpreter, 'polyscript', { XWorker });
64-
dispatch(script, type, false, CustomEvent);
64+
dispatch(script, type);
6565
return module[isAsync ? 'runAsync' : 'run'](interpreter, content);
6666
} finally {
6767
delete document.currentScript;

esm/utils.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,12 @@ const nodeInfo = (node, type) => ({
2121
* Notify the main thread about element "readiness".
2222
* @param {HTMLScriptElement | HTMLElement} target the script or custom-type element
2323
* @param {string} type the custom/type as event prefix
24-
* @param {boolean} worker `true` if dispatched form a worker, `false` if in main
25-
* @param {globalThis.CustomEvent} CustomEvent the right global to use
24+
* @param {boolean} [worker = false] `true` if dispatched form a worker, `false` by default if in main
25+
* @param {globalThis.CustomEvent} [CustomEvent = globalThis.CustomEvent] the `CustomEvent` to use
2626
*/
27-
const dispatch = (target, type, worker, CustomEvent) => {
27+
const dispatch = (target, type, worker = false, CE = CustomEvent) => {
2828
target.dispatchEvent(
29-
new CustomEvent(`${type}:ready`, {
29+
new CE(`${type}:ready`, {
3030
bubbles: true,
3131
detail: { worker },
3232
})

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,6 @@
7070
"coincident": "^0.11.6"
7171
},
7272
"worker": {
73-
"blob": "sha256-YCjLBQpKRjsu6QAzGWRouTXHL9/8bvDnOFrZ2RIb6lM="
73+
"blob": "sha256-WvSj4MN6jdsElxTRMemlcVupW1jtffGrgg0TzI94dsg="
7474
}
7575
}

0 commit comments

Comments
 (0)