element-internals-polyfill
Advanced tools
Comparing version 0.1.42 to 0.1.43
@@ -5,2 +5,9 @@ # Changelog | ||
### [0.1.43](https://github.com/calebdwilliams/element-internals-polyfill/compare/v0.1.42...v0.1.43) (2021-07-30) | ||
### Bug Fixes | ||
* polyfill manages onsubmit attributes set before form is initialized ([0e333a2](https://github.com/calebdwilliams/element-internals-polyfill/commit/0e333a27c8b7acd383ecf513a598f51b9eef7534)) | ||
### [0.1.42](https://github.com/calebdwilliams/element-internals-polyfill/compare/v0.1.41...v0.1.42) (2021-07-25) | ||
@@ -7,0 +14,0 @@ |
@@ -17,2 +17,3 @@ (function () { | ||
const documentFragmentMap = new WeakMap(); | ||
const onSubmitMap = new WeakMap(); | ||
@@ -61,3 +62,4 @@ const observerConfig$1 = { attributes: true, attributeFilter: ['disabled'] }; | ||
const formSubmitCallback = (event) => { | ||
const elements = formElementsMap.get(event.target); | ||
const form = event.target; | ||
const elements = formElementsMap.get(form); | ||
if (elements.size) { | ||
@@ -76,2 +78,9 @@ const nodes = Array.from(elements); | ||
} | ||
else if (onSubmitMap.get(form)) { | ||
const callback = onSubmitMap.get(form); | ||
const canceled = callback.call(form, event); | ||
if (canceled === false) { | ||
event.preventDefault(); | ||
} | ||
} | ||
} | ||
@@ -91,2 +100,6 @@ }; | ||
if (form) { | ||
if (form.onsubmit) { | ||
onSubmitMap.set(form, form.onsubmit.bind(form)); | ||
form.onsubmit = null; | ||
} | ||
const formElements = formElementsMap.get(form); | ||
@@ -93,0 +106,0 @@ if (formElements) { |
@@ -33,1 +33,3 @@ /** | ||
export declare const documentFragmentMap: WeakMap<DocumentFragment, MutationObserver>; | ||
/** Save references to the form onsubmit if present */ | ||
export declare const onSubmitMap: WeakMap<HTMLFormElement, Function>; |
{ | ||
"name": "element-internals-polyfill", | ||
"version": "0.1.42", | ||
"version": "0.1.43", | ||
"description": "A polyfill for the element internals specification", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.js", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
64144
860