element-internals-polyfill
Advanced tools
Comparing version 1.3.9 to 1.3.10
@@ -86,1 +86,19 @@ import { ValidityState } from './ValidityState.js'; | ||
export declare function isElementInternalsSupported(): boolean; | ||
/** | ||
* Forcibly applies the polyfill for CustomStateSet. | ||
* | ||
* https://developer.mozilla.org/en-US/docs/Web/API/CustomStateSet | ||
*/ | ||
export declare function forceCustomStateSetPolyfill(attachInternals?: HTMLElement['attachInternals']): void; | ||
/** | ||
* Forcibly applies the polyfill for ElementInternals. Useful for situations | ||
* like Chrome extensions where Chrome supports ElementInternals, but the | ||
* CustomElements polyfill is required. | ||
* | ||
* https://developer.mozilla.org/en-US/docs/Web/API/ElementInternals | ||
* | ||
* @param forceCustomStateSet Optional: when true, forces the | ||
* [CustomStateSet](https://developer.mozilla.org/en-US/docs/Web/API/CustomStateSet) | ||
* polyfill as well. | ||
*/ | ||
export declare function forceElementInternalsPolyfill(forceCustomStateSet?: boolean): void; |
@@ -6,2 +6,3 @@ import { ElementInternals } from './element-internals.js'; | ||
export * from './types.js'; | ||
export { forceCustomStateSetPolyfill, forceElementInternalsPolyfill, } from './element-internals.js'; | ||
declare global { | ||
@@ -8,0 +9,0 @@ interface Window { |
@@ -1,2 +0,2 @@ | ||
(function () { | ||
(function (exports) { | ||
'use strict'; | ||
@@ -198,2 +198,7 @@ | ||
const observer = new MutationObserver(fragmentObserverCallback); | ||
if (window?.ShadyDOM?.inUse && | ||
fragment.mode && | ||
fragment.host) { | ||
fragment = fragment.host; | ||
} | ||
observer.observe?.(fragment, { childList: true }); | ||
@@ -729,3 +734,23 @@ documentFragmentMap.set(fragment, observer); | ||
} | ||
if (!isElementInternalsSupported()) { | ||
let hasElementInternalsPolyfillBeenApplied = false; | ||
let hasCustomStateSetPolyfillBeenApplied = false; | ||
function forceCustomStateSetPolyfill(attachInternals) { | ||
if (hasCustomStateSetPolyfillBeenApplied) { | ||
return; | ||
} | ||
hasCustomStateSetPolyfillBeenApplied = true; | ||
window.CustomStateSet = CustomStateSet; | ||
if (attachInternals) { | ||
HTMLElement.prototype.attachInternals = function (...args) { | ||
const internals = attachInternals.call(this, args); | ||
internals.states = new CustomStateSet(this); | ||
return internals; | ||
}; | ||
} | ||
} | ||
function forceElementInternalsPolyfill(forceCustomStateSet = true) { | ||
if (hasElementInternalsPolyfillBeenApplied) { | ||
return; | ||
} | ||
hasElementInternalsPolyfillBeenApplied = true; | ||
if (typeof window !== 'undefined') { | ||
@@ -795,16 +820,25 @@ window.ElementInternals = ElementInternals; | ||
} | ||
if (typeof window !== 'undefined' && !window.CustomStateSet) { | ||
window.CustomStateSet = CustomStateSet; | ||
if (forceCustomStateSet || | ||
(typeof window !== "undefined" && !window.CustomStateSet)) { | ||
forceCustomStateSetPolyfill(); | ||
} | ||
} | ||
else if (typeof window !== 'undefined' && !window.CustomStateSet) { | ||
window.CustomStateSet = CustomStateSet; | ||
const attachInternals = HTMLElement.prototype.attachInternals; | ||
HTMLElement.prototype.attachInternals = function (...args) { | ||
const internals = attachInternals.call(this, args); | ||
internals.states = new CustomStateSet(this); | ||
return internals; | ||
}; | ||
const isCePolyfill = !!customElements.polyfillWrapFlushCallback; | ||
if (!isCePolyfill) { | ||
if (!isElementInternalsSupported()) { | ||
forceElementInternalsPolyfill(false); | ||
} | ||
else if (typeof window !== "undefined" && !window.CustomStateSet) { | ||
forceCustomStateSetPolyfill(HTMLElement.prototype.attachInternals); | ||
} | ||
} | ||
})(); | ||
exports.forceCustomStateSetPolyfill = forceCustomStateSetPolyfill; | ||
exports.forceElementInternalsPolyfill = forceElementInternalsPolyfill; | ||
Object.defineProperty(exports, '__esModule', { value: true }); | ||
return exports; | ||
})({}); |
{ | ||
"name": "element-internals-polyfill", | ||
"version": "1.3.9", | ||
"version": "1.3.10", | ||
"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
110415
1257