@locker/shared-dom
Advanced tools
Comparing version
@@ -10,6 +10,27 @@ /** | ||
const AttrProtoNameGetter = shared.ObjectLookupOwnGetter(Attr.prototype, 'name'); | ||
const AttrProtoNamespaceURIGetter = shared.ObjectLookupOwnGetter(Attr.prototype, 'namespaceURI'); | ||
const AttrProtoOwnerElementGetter = shared.ObjectLookupOwnGetter(Attr.prototype, 'ownerElement'); | ||
const { get: AttrProtoValueGetter, set: AttrProtoValueSetter } = shared.ReflectGetOwnPropertyDescriptor(Attr.prototype, 'value'); | ||
function AttrNameGetter(attr) { | ||
return shared.ReflectApply(AttrProtoNameGetter, attr, shared.emptyArray); | ||
} | ||
function AttrNamespaceURIGetter(attr) { | ||
return shared.ReflectApply(AttrProtoNamespaceURIGetter, attr, shared.emptyArray); | ||
} | ||
function AttrOwnerElementGetter(attr) { | ||
return shared.ReflectApply(AttrProtoOwnerElementGetter, attr, shared.emptyArray); | ||
} | ||
function AttrValueGetter(attr) { | ||
return shared.ReflectApply(AttrProtoValueGetter, attr, shared.emptyArray); | ||
} | ||
function AttrValueSetter(attr, value) { | ||
shared.ReflectApply(AttrProtoValueSetter, attr, [value]); | ||
} | ||
const { get: DocumentProtoCookieGetter, set: DocumentProtoCookieSetter, } = shared.ReflectGetOwnPropertyDescriptor(Document.prototype, 'cookie'); | ||
const { createElement: DocumentProtoCreateElement, execCommand: DocumentProtoExecCommand, getElementById: DocumentProtoGetElementById, } = Document.prototype; | ||
const { createComment: DocumentProtoCreateComment, createElement: DocumentProtoCreateElement, createElementNS: DocumentProtoCreateElementNS, getElementById: DocumentProtoGetElementById, } = Document.prototype; | ||
const DocumentProtoBodyGetter = shared.ObjectLookupOwnGetter(Document.prototype, 'body'); | ||
const DocumentProtoHeadGetter = shared.ObjectLookupOwnGetter(Document.prototype, 'head'); | ||
const { execCommand: DocumentProtoExecCommand } = Document.prototype; | ||
function DocumentBodyGetter(doc) { | ||
@@ -24,5 +45,11 @@ return shared.ReflectApply(DocumentProtoBodyGetter, doc, shared.emptyArray); | ||
} | ||
function DocumentCreateComment(doc, data = '') { | ||
return shared.ReflectApply(DocumentProtoCreateComment, doc, [data]); | ||
} | ||
function DocumentCreateElement(doc, ...args) { | ||
return shared.ReflectApply(DocumentProtoCreateElement, doc, args); | ||
} | ||
function DocumentCreateElementNS(doc, ...args) { | ||
return shared.ReflectApply(DocumentProtoCreateElementNS, doc, args); | ||
} | ||
function DocumentGetElementById(doc, id) { | ||
@@ -34,33 +61,26 @@ return shared.ReflectApply(DocumentProtoGetElementById, doc, [id]); | ||
} | ||
function nsCookieKey(key, ns) { | ||
return `${nsCookieRootKey(ns)}${key}`; | ||
} | ||
function nsCookieRootKey(ns) { | ||
return `LSKey-${ns}$`; | ||
} | ||
function nsCookieKey(key, ns) { | ||
return `${nsCookieRootKey(ns)}${key}`; | ||
} | ||
const { appendChild: NodeProtoAppendChild, isEqualNode: NodeProtoIsEqualNode } = Node.prototype; | ||
const NodeProtoChildNodesGetter = shared.ObjectLookupOwnGetter(Node.prototype, 'childNodes'); | ||
const NodeProtoTextContentSetter = shared.ObjectLookupOwnSetter(Node.prototype, 'textContent'); | ||
const NodeProtoNodeNameGetter = shared.ObjectLookupOwnGetter(Node.prototype, 'nodeName'); | ||
function NodeAppendChild(node, childNode) { | ||
return shared.ReflectApply(NodeProtoAppendChild, node, [childNode]); | ||
const { attachShadow: ElementProtoAttachShadow, insertAdjacentHTML: ElementProtoInsertAdjacentHTML, setAttribute: ElementProtoSetAttribute, setAttributeNS: ElementProtoSetAttributeNS, setAttributeNode: ElementProtoSetAttributeNode, } = Element.prototype; | ||
const { closest: ElementProtoClosest, getAttributeNode: ElementProtoGetAttributeNode, getAttributeNodeNS: ElementProtoGetAttributeNodeNS, querySelector: ElementProtoQuerySelector, removeAttributeNode: ElementProtoRemoveAttributeNode, setAttributeNodeNS: ElementProtoSetAttributeNodeNS, } = Element.prototype; | ||
const { get: ElementProtoInnerHTMLGetter, set: ElementProtoInnerHTMLSetter, } = shared.ReflectGetOwnPropertyDescriptor(Element.prototype, 'innerHTML'); | ||
const { get: ElementProtoOuterHTMLGetter, set: ElementProtoOuterHTMLSetter, } = shared.ReflectGetOwnPropertyDescriptor(Element.prototype, 'outerHTML'); | ||
const ElementProtoAttributesGetter = shared.ObjectLookupOwnGetter(Element.prototype, 'attributes'); | ||
function ElementClosest(el, selectors) { | ||
return shared.ReflectApply(ElementProtoClosest, el, [selectors]); | ||
} | ||
function NodeChildNodesGetter(node) { | ||
return shared.ReflectApply(NodeProtoChildNodesGetter, node, shared.emptyArray); | ||
function ElementInnerHTMLGetter(el) { | ||
return shared.ReflectApply(ElementProtoInnerHTMLGetter, el, shared.emptyArray); | ||
} | ||
function NodeIsEqualNode(node, otherNode) { | ||
return shared.ReflectApply(NodeProtoIsEqualNode, node, [otherNode]); | ||
} | ||
function NodeTextContentSetter(node, textContent) { | ||
shared.ReflectApply(NodeProtoTextContentSetter, node, [textContent]); | ||
} | ||
const { attachShadow: ElementProtoAttachShadow, getAttributeNode: ElementProtoGetAttributeNode, getAttributeNodeNS: ElementProtoGetAttributeNodeNS, insertAdjacentHTML: ElementProtoInsertAdjacentHTML, querySelector: ElementProtoQuerySelector, removeAttributeNode: ElementProtoRemoveAttributeNode, setAttribute: ElementProtoSetAttribute, setAttributeNS: ElementProtoSetAttributeNS, setAttributeNodeNS: ElementProtoSetAttributeNodeNS, setAttributeNode: ElementProtoSetAttributeNode, } = Element.prototype; | ||
const ElementProtoInnerHTMLSetter = shared.ObjectLookupOwnSetter(Element.prototype, 'innerHTML'); | ||
const ElementProtoOuterHTMLSetter = shared.ObjectLookupOwnSetter(Element.prototype, 'outerHTML'); | ||
const ElementProtoAttributesGetter = shared.ObjectLookupOwnGetter(Element.prototype, 'attributes'); | ||
function ElementInnerHTMLSetter(el, html) { | ||
shared.ReflectApply(ElementProtoInnerHTMLSetter, el, [html]); | ||
} | ||
function ElementOuterHTMLGetter(el) { | ||
return shared.ReflectApply(ElementProtoOuterHTMLGetter, el, shared.emptyArray); | ||
} | ||
function ElementOuterHTMLSetter(el, html) { | ||
@@ -98,6 +118,39 @@ shared.ReflectApply(ElementProtoOuterHTMLSetter, el, [html]); | ||
const HTMLTemplateElementProtoContentGetter = shared.ObjectLookupOwnGetter(HTMLTemplateElement.prototype, 'content'); | ||
function HTMLTemplateElementContentGetter(templateEl) { | ||
return shared.ReflectApply(HTMLTemplateElementProtoContentGetter, templateEl, shared.emptyArray); | ||
function HTMLTemplateElementContentGetter(template) { | ||
return shared.ReflectApply(HTMLTemplateElementProtoContentGetter, template, shared.emptyArray); | ||
} | ||
const { appendChild: NodeProtoAppendChild, cloneNode: NodeProtoCloneNode, isEqualNode: NodeProtoIsEqualNode, } = Node.prototype; | ||
const NodeProtoChildNodesGetter = shared.ObjectLookupOwnGetter(Node.prototype, 'childNodes'); | ||
const NodeProtoFirstChildGetter = shared.ObjectLookupOwnGetter(Node.prototype, 'firstChild'); | ||
const NodeProtoNodeNameGetter = shared.ObjectLookupOwnGetter(Node.prototype, 'nodeName'); | ||
const NodeProtoOwnerDocumentGetter = shared.ObjectLookupOwnGetter(Node.prototype, 'ownerDocument'); | ||
const NodeProtoTextContentSetter = shared.ObjectLookupOwnSetter(Node.prototype, 'textContent'); | ||
function NodeAppendChild(node, childNode) { | ||
return shared.ReflectApply(NodeProtoAppendChild, node, [childNode]); | ||
} | ||
function NodeChildNodesGetter(node) { | ||
return shared.ReflectApply(NodeProtoChildNodesGetter, node, shared.emptyArray); | ||
} | ||
function NodeClone(node, deep = false) { | ||
return shared.ReflectApply(NodeProtoCloneNode, node, [deep]); | ||
} | ||
function NodeFirstChildGetter(node) { | ||
return shared.ReflectApply(NodeProtoFirstChildGetter, node, shared.emptyArray); | ||
} | ||
function NodeIsEqualNode(node, otherNode) { | ||
return shared.ReflectApply(NodeProtoIsEqualNode, node, [otherNode]); | ||
} | ||
function NodeNameGetter(node) { | ||
// Normalize nodeName to upper case. | ||
// See https://johnresig.com/blog/nodename-case-sensitivity/. | ||
return shared.StringToUpperCase(shared.ReflectApply(NodeProtoNodeNameGetter, node, shared.emptyArray)); | ||
} | ||
function NodeOwnerDocumentGetter(node) { | ||
return shared.ReflectApply(NodeProtoOwnerDocumentGetter, node, shared.emptyArray); | ||
} | ||
function NodeTextContentSetter(node, textContent) { | ||
shared.ReflectApply(NodeProtoTextContentSetter, node, [textContent]); | ||
} | ||
const { document } = window; | ||
@@ -137,24 +190,2 @@ const leftTpl = DocumentCreateElement(document, 'template'); | ||
const AttrProtoValueDescriptor = shared.ReflectGetOwnPropertyDescriptor(Attr.prototype, 'value'); | ||
const AttrProtoNameGetter = shared.ObjectLookupOwnGetter(Attr.prototype, 'name'); | ||
const AttrProtoNamespaceURIGetter = shared.ObjectLookupOwnGetter(Attr.prototype, 'namespaceURI'); | ||
const AttrProtoOwnerElementGetter = shared.ObjectLookupOwnGetter(Attr.prototype, 'ownerElement'); | ||
const AttrProtoValueGetter = AttrProtoValueDescriptor.get; | ||
const AttrProtoValueSetter = AttrProtoValueDescriptor.set; | ||
function AttrNameGetter(attr) { | ||
return shared.ReflectApply(AttrProtoNameGetter, attr, shared.emptyArray); | ||
} | ||
function AttrNamespaceURIGetter(attr) { | ||
return shared.ReflectApply(AttrProtoNamespaceURIGetter, attr, shared.emptyArray); | ||
} | ||
function AttrOwnerElementGetter(attr) { | ||
return shared.ReflectApply(AttrProtoOwnerElementGetter, attr, shared.emptyArray); | ||
} | ||
function AttrValueGetter(attr) { | ||
return shared.ReflectApply(AttrProtoValueGetter, attr, shared.emptyArray); | ||
} | ||
function AttrValueSetter(attr, value) { | ||
shared.ReflectApply(AttrProtoValueSetter, attr, [value]); | ||
} | ||
const BlobProtoSizeGetter = shared.ObjectLookupOwnGetter(Blob.prototype, 'size'); | ||
@@ -171,3 +202,3 @@ const { slice: BlobProtoSlice } = Blob.prototype; | ||
function BlobTypeGetter(blob) { | ||
return shared.ReflectApply(BlobProtoTypeGetter, blob, shared.emptyArray); | ||
return shared.StringToLowerCase(shared.ReflectApply(BlobProtoTypeGetter, blob, shared.emptyArray)); | ||
} | ||
@@ -181,3 +212,3 @@ | ||
const { define: CustomElementRegistryDefineValue, get: CustomElementRegistryGet, } = CustomElementRegistry.prototype; | ||
const { define: CustomElementRegistryProtoDefine, get: CustomElementRegistryProtoGet, } = CustomElementRegistry.prototype; | ||
@@ -190,10 +221,15 @@ const { getElementById: DocumentFragmentProtoGetElementById } = DocumentFragment.prototype; | ||
const DOMTokenListProtoValueGetter = shared.ObjectLookupOwnGetter(DOMTokenList.prototype, 'value'); | ||
function DOMTokenListValueGetter(tokenList) { | ||
return shared.ReflectApply(DOMTokenListProtoValueGetter, tokenList, shared.emptyArray); | ||
} | ||
const HTMLElementProtoDatasetGetter = shared.ObjectLookupOwnGetter(HTMLElement.prototype, 'dataset'); | ||
const HTMLElementProtoStyleGetter = shared.ObjectLookupOwnGetter(HTMLElement.prototype, 'style'); | ||
const HTMLElementProtoInnerTextSetter = shared.ObjectLookupOwnSetter(HTMLElement.prototype, 'innerText'); | ||
const HTMLElementProtoOuterTextSetter = shared.ObjectLookupOwnSetter(HTMLElement.prototype, 'outerText'); | ||
const { addEventListener: EventTargetProtoAddEventListener } = EventTarget.prototype; | ||
function EventTargetAddEventListener(target, ...args) { | ||
return shared.ReflectApply(EventTargetProtoAddEventListener, target, args); | ||
} | ||
const HTMLAnchorElementProtoHostnameGetter = shared.ObjectLookupOwnGetter(HTMLAnchorElement.prototype, 'hostname'); | ||
const { get: HTMLAnchorElementProtoHrefGetter, set: HTMLAnchorElementProtoHrefSetter, } = shared.ReflectGetOwnPropertyDescriptor(HTMLAnchorElement.prototype, 'href'); | ||
const HTMLAnchorElementProtoHostnameGetter = shared.ObjectLookupOwnGetter(HTMLAnchorElement.prototype, 'hostname'); | ||
const HTMLAnchorElementProtoPathnameGetter = shared.ObjectLookupOwnGetter(HTMLAnchorElement.prototype, 'pathname'); | ||
const HTMLAnchorElementProtoProtocolGetter = shared.ObjectLookupOwnGetter(HTMLAnchorElement.prototype, 'protocol'); | ||
function HTMLAnchorElementHostnameGetter(anchor) { | ||
@@ -208,3 +244,31 @@ return shared.ReflectApply(HTMLAnchorElementProtoHostnameGetter, anchor, shared.emptyArray); | ||
} | ||
function HTMLAnchorElementPathnameGetter(anchor) { | ||
return shared.ReflectApply(HTMLAnchorElementProtoPathnameGetter, anchor, shared.emptyArray); | ||
} | ||
function HTMLAnchorElementProtocolGetter(anchor) { | ||
return shared.ReflectApply(HTMLAnchorElementProtoProtocolGetter, anchor, shared.emptyArray); | ||
} | ||
// The innerText and outerText setters may be undefined. | ||
const HTMLElementProtoInnerTextSetter = shared.ObjectLookupOwnSetter(HTMLElement.prototype, 'innerText'); | ||
const HTMLElementProtoOuterTextSetter = shared.ObjectLookupOwnSetter(HTMLElement.prototype, 'outerText'); | ||
const HTMLElementProtoDatasetGetter = shared.ObjectLookupOwnGetter(HTMLElement.prototype, 'dataset'); | ||
const HTMLElementProtoStyleGetter = shared.ObjectLookupOwnGetter(HTMLElement.prototype, 'style'); | ||
function HTMLElementDatasetGetter(el) { | ||
return shared.ReflectApply(HTMLElementProtoDatasetGetter, el, shared.emptyArray); | ||
} | ||
const HTMLElementInnerTextSetter = HTMLElementProtoInnerTextSetter | ||
? function HTMLElementInnerTextSetter(el, text) { | ||
shared.ReflectApply(HTMLElementProtoInnerTextSetter, el, [text]); | ||
} | ||
: function HTMLElementInnerTextSetter(_el, _text) { }; | ||
const HTMLElementOuterTextSetter = HTMLElementProtoOuterTextSetter | ||
? function HTMLElementOuterTextSetter(el, text) { | ||
shared.ReflectApply(HTMLElementProtoOuterTextSetter, el, [text]); | ||
} | ||
: function HTMLElementOuterTextSetter(_el, _text) { }; | ||
function HTMLElementStyleGetter(el) { | ||
return shared.ReflectApply(HTMLElementProtoStyleGetter, el, shared.emptyArray); | ||
} | ||
const HTMLFrameElementProtoContentWindowGetter = shared.ObjectLookupOwnGetter(HTMLFrameElement.prototype, 'contentWindow'); | ||
@@ -216,9 +280,18 @@ function HTMLFrameElementContentWindowGetter(frame) { | ||
const HTMLIFrameElementProtoContentWindowGetter = shared.ObjectLookupOwnGetter(HTMLIFrameElement.prototype, 'contentWindow'); | ||
const HTMLIframeElementProtoSrcSetter = shared.ObjectLookupOwnSetter(HTMLIFrameElement.prototype, 'src'); | ||
function HTMLIframeElementContentWindowGetter(iframe) { | ||
const HTMLIFrameElementProtoSrcSetter = shared.ObjectLookupOwnSetter(HTMLIFrameElement.prototype, 'src'); | ||
function HTMLIFrameElementContentWindowGetter(iframe) { | ||
return shared.ReflectApply(HTMLIFrameElementProtoContentWindowGetter, iframe, shared.emptyArray); | ||
} | ||
function HTMLIFrameElementSrcSetter(iframe, src) { | ||
shared.ReflectApply(HTMLIFrameElementProtoSrcSetter, iframe, [src]); | ||
} | ||
const HTMLLinkElementProtoRelSetter = shared.ObjectLookupOwnSetter(HTMLLinkElement.prototype, 'rel'); | ||
const HTMLLinkElementProtoRelListSetter = shared.ObjectLookupOwnSetter(HTMLLinkElement.prototype, 'relList'); | ||
function HTMLLinkElementRelSetter(link, rel) { | ||
shared.ReflectApply(HTMLLinkElementProtoRelSetter, link, [rel]); | ||
} | ||
function HTMLLinkElementRelListSetter(link, relList) { | ||
shared.ReflectApply(HTMLLinkElementProtoRelListSetter, link, [relList]); | ||
} | ||
@@ -234,9 +307,7 @@ const HTMLObjectProtoContentWindowGetter = shared.ObjectLookupOwnGetter(HTMLObjectElement.prototype, 'contentWindow'); | ||
const HTMLScriptElementProtoSrcDescriptor = shared.ReflectGetOwnPropertyDescriptor(HTMLScriptElement.prototype, 'src'); | ||
const HTMLScriptElementProtoSrcGetter = HTMLScriptElementProtoSrcDescriptor.get; | ||
const HTMLScriptElementProtoSrcSetter = HTMLScriptElementProtoSrcDescriptor.set; | ||
const { get: HTMLScriptElementProtoSrcGetter, set: HTMLScriptElementProtoSrcSetter, } = shared.ReflectGetOwnPropertyDescriptor(HTMLScriptElement.prototype, 'src'); | ||
const MessageEventProtoSourceGetter = shared.ObjectLookupOwnGetter(MessageEvent.prototype, 'source'); | ||
function MessageEventSourceGetter(messageEvt) { | ||
return shared.ReflectApply(MessageEventProtoSourceGetter, messageEvt, shared.emptyArray); | ||
function MessageEventSourceGetter(messageEvent) { | ||
return shared.ReflectApply(MessageEventProtoSourceGetter, messageEvent, shared.emptyArray); | ||
} | ||
@@ -256,8 +327,14 @@ | ||
const SVGElementProtoDatasetGetter = shared.ObjectLookupOwnGetter(SVGElement.prototype, 'dataset'); | ||
function SVGElementDatasetGetter(svg) { | ||
return shared.ReflectApply(SVGElementProtoDatasetGetter, svg, shared.emptyArray); | ||
} | ||
const { createObjectURL: URLCreateObjectURL, revokeObjectURL: URLRevokeObjectURL } = URL; | ||
const allowlistPatched = ['opener', 'parent']; | ||
const allowListRaw = ['close', 'closed', 'focus', 'postMessage']; | ||
const { clearInterval: WindowStaticClearInterval, setInterval: WindowStaticSetInterval } = window; | ||
const ALLOW_LIST_PATCHED = ['opener', 'parent']; | ||
const ALLOW_LIST_RAW = ['close', 'closed', 'focus', 'postMessage']; | ||
const { clearInterval: WindowStaticClearInterval } = window; | ||
const WindowStaticOpenerGetter = shared.ObjectLookupOwnGetter(window, 'opener'); | ||
const WindowStaticParentGetter = shared.ObjectLookupOwnGetter(window, 'parent'); | ||
const WindowStaticSelfGetter = shared.ObjectLookupOwnGetter(window, 'self'); | ||
function bind(func, context) { | ||
@@ -269,9 +346,9 @@ const bound = shared.FunctionBind(func, context); | ||
const patchedWindowMap = new shared.WeakMapCtor(); | ||
// setInterval and clearInterval are part of WindowOrGlobalScope mixin, they do | ||
// not belong on a prototype https://developer.mozilla.org/en-US/docs/Web/API/WindowOrWorkerGlobalScope | ||
const { encodeURIComponent: WindowStaticEncodeURIComponent, fetch: WindowStaticFetch, open: WindowStaticOpen, } = window; | ||
// setInterval and clearInterval are part of WindowOrGlobalScope mixin, they are | ||
// not on Window.prototype. See https://developer.mozilla.org/en-US/docs/Web/API/WindowOrWorkerGlobalScope. | ||
const { decodeURIComponent: WindowStaticDecodeURIComponent, encodeURIComponent: WindowStaticEncodeURIComponent, fetch: WindowStaticFetch, open: WindowStaticOpen, setInterval: WindowStaticSetInterval, setTimeout: WindowStaticSetTimeout, } = window; | ||
function createPatchedWindow(rawWindow) { | ||
const patchedWindow = {}; | ||
for (let i = 0, len = allowListRaw.length; i < len; i += 1) { | ||
const key = allowListRaw[i]; | ||
for (let i = 0, len = ALLOW_LIST_RAW.length; i < len; i += 1) { | ||
const key = ALLOW_LIST_RAW[i]; | ||
const originalDescriptor = shared.ReflectGetOwnPropertyDescriptor(rawWindow, key); | ||
@@ -294,4 +371,4 @@ if (originalDescriptor) { | ||
} | ||
for (let i = 0, len = allowlistPatched.length; i < len; i += 1) { | ||
const key = allowlistPatched[i]; | ||
for (let i = 0, len = ALLOW_LIST_PATCHED.length; i < len; i += 1) { | ||
const key = ALLOW_LIST_PATCHED[i]; | ||
const patchedDescriptor = shared.ObjectCreate(null); | ||
@@ -327,20 +404,60 @@ const originalDescriptor = shared.ReflectGetOwnPropertyDescriptor(rawWindow, key); | ||
} | ||
function WindowOpenerGetter(win) { | ||
return shared.ReflectApply(WindowStaticOpenerGetter, win, shared.emptyArray); | ||
} | ||
function WindowParentGetter(win) { | ||
return shared.ReflectApply(WindowStaticParentGetter, win, shared.emptyArray); | ||
} | ||
function WindowSelfGetter(win) { | ||
return shared.ReflectApply(WindowStaticSelfGetter, win, shared.emptyArray); | ||
} | ||
function WindowSetInterval(win, ...args) { | ||
return shared.ReflectApply(WindowStaticSetInterval, win, args); | ||
} | ||
function isWindowLike(value) { | ||
// fast check to narrow down when to do the slow check for window objects | ||
// window.top is unforgeable, this means this check should be safe from | ||
// user-intervention to try to bypass this check. | ||
return shared.ObjectHasOwnProperty(value, 'top'); | ||
} | ||
function isWindow(value) { | ||
// slower check that must certainly detect a window object | ||
try { | ||
// window.self getter only works for a window object, otherwise it throws, | ||
// additionally, this works fine for a detached window as well, which is | ||
// important since it will guarantee that this check works also for iframes | ||
// that are disconnected, and could be connected later on, that should not | ||
// bypass this check. This check is is also equivalent to window.frames, and | ||
// here is the very simple spec for this getter: | ||
// https://html.spec.whatwg.org/multipage/window-object.html#dom-self | ||
WindowSelfGetter(value); | ||
return true; | ||
// eslint-disable-next-line no-empty | ||
} | ||
catch (_a) { } | ||
return false; | ||
} | ||
const XhrCtor = XMLHttpRequest; | ||
const XhrProto = XhrCtor.prototype; | ||
const { open: XhrProtoOpen, send: XhrProtoSend } = XhrProto; | ||
const XhrOnReadyStateChangeSetter = shared.ObjectLookupOwnSetter(XhrProto, 'onreadystatechange'); | ||
const XhrReadyStateGetter = shared.ObjectLookupOwnGetter(XhrProto, 'readyState'); | ||
const XhrResponseTextGetter = shared.ObjectLookupOwnGetter(XhrProto, 'responseText'); | ||
const XhrStatusGetter = shared.ObjectLookupOwnGetter(XhrProto, 'status'); | ||
const XhrWithCredentialsSetter = shared.ObjectLookupOwnSetter(XhrProto, 'withCredentials'); | ||
const { send: XhrProtoSend } = XhrProto; | ||
const XhrProtoResponseTextGetter = shared.ObjectLookupOwnGetter(XhrProto, 'responseText'); | ||
const XhrProtoStatusGetter = shared.ObjectLookupOwnGetter(XhrProto, 'status'); | ||
const XhrProtoWithCredentialsSetter = shared.ObjectLookupOwnSetter(XhrProto, 'withCredentials'); | ||
const { open: XhrProtoOpen } = XhrProto; | ||
function XhrOpen(xhr, requestMethod, url, async = true) { | ||
return shared.ReflectApply(XhrProtoOpen, xhr, [requestMethod, url, async]); | ||
} | ||
function XhrResponseTextGetter(xhr) { | ||
return shared.ReflectApply(XhrProtoResponseTextGetter, xhr, shared.emptyArray); | ||
} | ||
function XhrSend(xhr) { | ||
return shared.ReflectApply(XhrProtoSend, xhr, shared.emptyArray); | ||
} | ||
function XhrStatusGetter(xhr) { | ||
return shared.ReflectApply(XhrProtoStatusGetter, xhr, shared.emptyArray); | ||
} | ||
function XhrWithCredentialsSetter(xhr, bool) { | ||
shared.ReflectApply(XhrProtoWithCredentialsSetter, xhr, [bool]); | ||
} | ||
@@ -350,7 +467,2 @@ exports.AttrNameGetter = AttrNameGetter; | ||
exports.AttrOwnerElementGetter = AttrOwnerElementGetter; | ||
exports.AttrProtoNameGetter = AttrProtoNameGetter; | ||
exports.AttrProtoNamespaceURIGetter = AttrProtoNamespaceURIGetter; | ||
exports.AttrProtoOwnerElementGetter = AttrProtoOwnerElementGetter; | ||
exports.AttrProtoValueGetter = AttrProtoValueGetter; | ||
exports.AttrProtoValueSetter = AttrProtoValueSetter; | ||
exports.AttrValueGetter = AttrValueGetter; | ||
@@ -366,32 +478,28 @@ exports.AttrValueSetter = AttrValueSetter; | ||
exports.CookieStoreProtoSet = CookieStoreProtoSet; | ||
exports.CustomElementRegistryDefineValue = CustomElementRegistryDefineValue; | ||
exports.CustomElementRegistryGet = CustomElementRegistryGet; | ||
exports.DOMTokenListProtoValueGetter = DOMTokenListProtoValueGetter; | ||
exports.CustomElementRegistryProtoDefine = CustomElementRegistryProtoDefine; | ||
exports.CustomElementRegistryProtoGet = CustomElementRegistryProtoGet; | ||
exports.DOMTokenListValueGetter = DOMTokenListValueGetter; | ||
exports.DocumentBodyGetter = DocumentBodyGetter; | ||
exports.DocumentCookieGetter = DocumentCookieGetter; | ||
exports.DocumentCookieSetter = DocumentCookieSetter; | ||
exports.DocumentCreateComment = DocumentCreateComment; | ||
exports.DocumentCreateElement = DocumentCreateElement; | ||
exports.DocumentCreateElementNS = DocumentCreateElementNS; | ||
exports.DocumentFragmentGetElementById = DocumentFragmentGetElementById; | ||
exports.DocumentGetElementById = DocumentGetElementById; | ||
exports.DocumentHeadGetter = DocumentHeadGetter; | ||
exports.DocumentProtoBodyGetter = DocumentProtoBodyGetter; | ||
exports.DocumentProtoCreateElement = DocumentProtoCreateElement; | ||
exports.DocumentProtoExecCommand = DocumentProtoExecCommand; | ||
exports.DocumentProtoGetElementById = DocumentProtoGetElementById; | ||
exports.DocumentProtoHeadGetter = DocumentProtoHeadGetter; | ||
exports.ElementAttributesGetter = ElementAttributesGetter; | ||
exports.ElementClosest = ElementClosest; | ||
exports.ElementGetAttributeNode = ElementGetAttributeNode; | ||
exports.ElementGetAttributeNodeNS = ElementGetAttributeNodeNS; | ||
exports.ElementInnerHTMLGetter = ElementInnerHTMLGetter; | ||
exports.ElementInnerHTMLSetter = ElementInnerHTMLSetter; | ||
exports.ElementOuterHTMLGetter = ElementOuterHTMLGetter; | ||
exports.ElementOuterHTMLSetter = ElementOuterHTMLSetter; | ||
exports.ElementProtoAttachShadow = ElementProtoAttachShadow; | ||
exports.ElementProtoGetAttributeNode = ElementProtoGetAttributeNode; | ||
exports.ElementProtoGetAttributeNodeNS = ElementProtoGetAttributeNodeNS; | ||
exports.ElementProtoInsertAdjacentHTML = ElementProtoInsertAdjacentHTML; | ||
exports.ElementProtoQuerySelector = ElementProtoQuerySelector; | ||
exports.ElementProtoRemoveAttributeNode = ElementProtoRemoveAttributeNode; | ||
exports.ElementProtoSetAttribute = ElementProtoSetAttribute; | ||
exports.ElementProtoSetAttributeNS = ElementProtoSetAttributeNS; | ||
exports.ElementProtoSetAttributeNode = ElementProtoSetAttributeNode; | ||
exports.ElementProtoSetAttributeNodeNS = ElementProtoSetAttributeNodeNS; | ||
exports.ElementQuerySelector = ElementQuerySelector; | ||
@@ -403,17 +511,21 @@ exports.ElementRemoveAttributeNode = ElementRemoveAttributeNode; | ||
exports.ElementSetAttributeNodeNS = ElementSetAttributeNodeNS; | ||
exports.EventTargetAddEventListener = EventTargetAddEventListener; | ||
exports.HTMLAnchorElementHostnameGetter = HTMLAnchorElementHostnameGetter; | ||
exports.HTMLAnchorElementHrefGetter = HTMLAnchorElementHrefGetter; | ||
exports.HTMLAnchorElementHrefSetter = HTMLAnchorElementHrefSetter; | ||
exports.HTMLElementProtoDatasetGetter = HTMLElementProtoDatasetGetter; | ||
exports.HTMLElementProtoInnerTextSetter = HTMLElementProtoInnerTextSetter; | ||
exports.HTMLElementProtoOuterTextSetter = HTMLElementProtoOuterTextSetter; | ||
exports.HTMLElementProtoStyleGetter = HTMLElementProtoStyleGetter; | ||
exports.HTMLAnchorElementPathnameGetter = HTMLAnchorElementPathnameGetter; | ||
exports.HTMLAnchorElementProtocolGetter = HTMLAnchorElementProtocolGetter; | ||
exports.HTMLElementDatasetGetter = HTMLElementDatasetGetter; | ||
exports.HTMLElementInnerTextSetter = HTMLElementInnerTextSetter; | ||
exports.HTMLElementOuterTextSetter = HTMLElementOuterTextSetter; | ||
exports.HTMLElementStyleGetter = HTMLElementStyleGetter; | ||
exports.HTMLFrameElementContentWindowGetter = HTMLFrameElementContentWindowGetter; | ||
exports.HTMLIframeElementContentWindowGetter = HTMLIframeElementContentWindowGetter; | ||
exports.HTMLIframeElementProtoSrcSetter = HTMLIframeElementProtoSrcSetter; | ||
exports.HTMLLinkElementProtoRelListSetter = HTMLLinkElementProtoRelListSetter; | ||
exports.HTMLLinkElementProtoRelSetter = HTMLLinkElementProtoRelSetter; | ||
exports.HTMLIFrameElementContentWindowGetter = HTMLIFrameElementContentWindowGetter; | ||
exports.HTMLIFrameElementSrcSetter = HTMLIFrameElementSrcSetter; | ||
exports.HTMLLinkElementRelListSetter = HTMLLinkElementRelListSetter; | ||
exports.HTMLLinkElementRelSetter = HTMLLinkElementRelSetter; | ||
exports.HTMLObjectElementContentWindowGetter = HTMLObjectElementContentWindowGetter; | ||
exports.HTMLScriptElementProtoSrcGetter = HTMLScriptElementProtoSrcGetter; | ||
exports.HTMLScriptElementProtoSrcSetter = HTMLScriptElementProtoSrcSetter; | ||
exports.HTMLTemplateElementContentGetter = HTMLTemplateElementContentGetter; | ||
exports.MessageEventSourceGetter = MessageEventSourceGetter; | ||
@@ -423,8 +535,11 @@ exports.NamedNodeMapProtoSetNamedItem = NamedNodeMapProtoSetNamedItem; | ||
exports.NodeChildNodesGetter = NodeChildNodesGetter; | ||
exports.NodeClone = NodeClone; | ||
exports.NodeFirstChildGetter = NodeFirstChildGetter; | ||
exports.NodeIsEqualNode = NodeIsEqualNode; | ||
exports.NodeProtoNodeNameGetter = NodeProtoNodeNameGetter; | ||
exports.NodeNameGetter = NodeNameGetter; | ||
exports.NodeOwnerDocumentGetter = NodeOwnerDocumentGetter; | ||
exports.NodeTextContentSetter = NodeTextContentSetter; | ||
exports.RangeProtoCreateContextualFragment = RangeProtoCreateContextualFragment; | ||
exports.RequestURLGetter = RequestURLGetter; | ||
exports.SVGElementProtoDatasetGetter = SVGElementProtoDatasetGetter; | ||
exports.SVGElementDatasetGetter = SVGElementDatasetGetter; | ||
exports.StorageProtoGetItem = StorageProtoGetItem; | ||
@@ -437,12 +552,15 @@ exports.StorageProtoKey = StorageProtoKey; | ||
exports.WindowClearInterval = WindowClearInterval; | ||
exports.WindowOpenerGetter = WindowOpenerGetter; | ||
exports.WindowParentGetter = WindowParentGetter; | ||
exports.WindowSelfGetter = WindowSelfGetter; | ||
exports.WindowSetInterval = WindowSetInterval; | ||
exports.WindowStaticDecodeURIComponent = WindowStaticDecodeURIComponent; | ||
exports.WindowStaticEncodeURIComponent = WindowStaticEncodeURIComponent; | ||
exports.WindowStaticFetch = WindowStaticFetch; | ||
exports.WindowStaticOpen = WindowStaticOpen; | ||
exports.WindowStaticSetInterval = WindowStaticSetInterval; | ||
exports.WindowStaticSetTimeout = WindowStaticSetTimeout; | ||
exports.XhrCtor = XhrCtor; | ||
exports.XhrOnReadyStateChangeSetter = XhrOnReadyStateChangeSetter; | ||
exports.XhrOpen = XhrOpen; | ||
exports.XhrProtoOpen = XhrProtoOpen; | ||
exports.XhrProtoSend = XhrProtoSend; | ||
exports.XhrReadyStateGetter = XhrReadyStateGetter; | ||
exports.XhrResponseTextGetter = XhrResponseTextGetter; | ||
@@ -455,5 +573,7 @@ exports.XhrSend = XhrSend; | ||
exports.isSharedElement = isSharedElement; | ||
exports.isWindow = isWindow; | ||
exports.isWindowLike = isWindowLike; | ||
exports.nsCookieKey = nsCookieKey; | ||
exports.nsCookieRootKey = nsCookieRootKey; | ||
exports.patchedWindowMap = patchedWindowMap; | ||
/** version: 0.13.5 */ | ||
/** version: 0.13.6 */ |
/** | ||
* Copyright (C) 2019 salesforce.com, inc. | ||
*/ | ||
import { ReflectGetOwnPropertyDescriptor, ObjectLookupOwnGetter, ReflectApply, emptyArray, ObjectLookupOwnSetter, ObjectLookupOwnValue, WeakMapCtor, ReflectSetPrototypeOf, ReflectDefineProperty, ObjectCreate, WeakMapGet, WeakMapSet, FunctionBind } from '@locker/shared'; | ||
import { ObjectLookupOwnGetter, ReflectGetOwnPropertyDescriptor, ReflectApply, emptyArray, ObjectLookupOwnSetter, StringToUpperCase, StringToLowerCase, ObjectLookupOwnValue, WeakMapCtor, ReflectSetPrototypeOf, ReflectDefineProperty, ObjectCreate, WeakMapGet, WeakMapSet, ObjectHasOwnProperty, FunctionBind } from '@locker/shared'; | ||
const AttrProtoNameGetter = ObjectLookupOwnGetter(Attr.prototype, 'name'); | ||
const AttrProtoNamespaceURIGetter = ObjectLookupOwnGetter(Attr.prototype, 'namespaceURI'); | ||
const AttrProtoOwnerElementGetter = ObjectLookupOwnGetter(Attr.prototype, 'ownerElement'); | ||
const { get: AttrProtoValueGetter, set: AttrProtoValueSetter } = ReflectGetOwnPropertyDescriptor(Attr.prototype, 'value'); | ||
function AttrNameGetter(attr) { | ||
return ReflectApply(AttrProtoNameGetter, attr, emptyArray); | ||
} | ||
function AttrNamespaceURIGetter(attr) { | ||
return ReflectApply(AttrProtoNamespaceURIGetter, attr, emptyArray); | ||
} | ||
function AttrOwnerElementGetter(attr) { | ||
return ReflectApply(AttrProtoOwnerElementGetter, attr, emptyArray); | ||
} | ||
function AttrValueGetter(attr) { | ||
return ReflectApply(AttrProtoValueGetter, attr, emptyArray); | ||
} | ||
function AttrValueSetter(attr, value) { | ||
ReflectApply(AttrProtoValueSetter, attr, [value]); | ||
} | ||
const { get: DocumentProtoCookieGetter, set: DocumentProtoCookieSetter, } = ReflectGetOwnPropertyDescriptor(Document.prototype, 'cookie'); | ||
const { createElement: DocumentProtoCreateElement, execCommand: DocumentProtoExecCommand, getElementById: DocumentProtoGetElementById, } = Document.prototype; | ||
const { createComment: DocumentProtoCreateComment, createElement: DocumentProtoCreateElement, createElementNS: DocumentProtoCreateElementNS, getElementById: DocumentProtoGetElementById, } = Document.prototype; | ||
const DocumentProtoBodyGetter = ObjectLookupOwnGetter(Document.prototype, 'body'); | ||
const DocumentProtoHeadGetter = ObjectLookupOwnGetter(Document.prototype, 'head'); | ||
const { execCommand: DocumentProtoExecCommand } = Document.prototype; | ||
function DocumentBodyGetter(doc) { | ||
@@ -19,5 +40,11 @@ return ReflectApply(DocumentProtoBodyGetter, doc, emptyArray); | ||
} | ||
function DocumentCreateComment(doc, data = '') { | ||
return ReflectApply(DocumentProtoCreateComment, doc, [data]); | ||
} | ||
function DocumentCreateElement(doc, ...args) { | ||
return ReflectApply(DocumentProtoCreateElement, doc, args); | ||
} | ||
function DocumentCreateElementNS(doc, ...args) { | ||
return ReflectApply(DocumentProtoCreateElementNS, doc, args); | ||
} | ||
function DocumentGetElementById(doc, id) { | ||
@@ -29,33 +56,26 @@ return ReflectApply(DocumentProtoGetElementById, doc, [id]); | ||
} | ||
function nsCookieKey(key, ns) { | ||
return `${nsCookieRootKey(ns)}${key}`; | ||
} | ||
function nsCookieRootKey(ns) { | ||
return `LSKey-${ns}$`; | ||
} | ||
function nsCookieKey(key, ns) { | ||
return `${nsCookieRootKey(ns)}${key}`; | ||
} | ||
const { appendChild: NodeProtoAppendChild, isEqualNode: NodeProtoIsEqualNode } = Node.prototype; | ||
const NodeProtoChildNodesGetter = ObjectLookupOwnGetter(Node.prototype, 'childNodes'); | ||
const NodeProtoTextContentSetter = ObjectLookupOwnSetter(Node.prototype, 'textContent'); | ||
const NodeProtoNodeNameGetter = ObjectLookupOwnGetter(Node.prototype, 'nodeName'); | ||
function NodeAppendChild(node, childNode) { | ||
return ReflectApply(NodeProtoAppendChild, node, [childNode]); | ||
const { attachShadow: ElementProtoAttachShadow, insertAdjacentHTML: ElementProtoInsertAdjacentHTML, setAttribute: ElementProtoSetAttribute, setAttributeNS: ElementProtoSetAttributeNS, setAttributeNode: ElementProtoSetAttributeNode, } = Element.prototype; | ||
const { closest: ElementProtoClosest, getAttributeNode: ElementProtoGetAttributeNode, getAttributeNodeNS: ElementProtoGetAttributeNodeNS, querySelector: ElementProtoQuerySelector, removeAttributeNode: ElementProtoRemoveAttributeNode, setAttributeNodeNS: ElementProtoSetAttributeNodeNS, } = Element.prototype; | ||
const { get: ElementProtoInnerHTMLGetter, set: ElementProtoInnerHTMLSetter, } = ReflectGetOwnPropertyDescriptor(Element.prototype, 'innerHTML'); | ||
const { get: ElementProtoOuterHTMLGetter, set: ElementProtoOuterHTMLSetter, } = ReflectGetOwnPropertyDescriptor(Element.prototype, 'outerHTML'); | ||
const ElementProtoAttributesGetter = ObjectLookupOwnGetter(Element.prototype, 'attributes'); | ||
function ElementClosest(el, selectors) { | ||
return ReflectApply(ElementProtoClosest, el, [selectors]); | ||
} | ||
function NodeChildNodesGetter(node) { | ||
return ReflectApply(NodeProtoChildNodesGetter, node, emptyArray); | ||
function ElementInnerHTMLGetter(el) { | ||
return ReflectApply(ElementProtoInnerHTMLGetter, el, emptyArray); | ||
} | ||
function NodeIsEqualNode(node, otherNode) { | ||
return ReflectApply(NodeProtoIsEqualNode, node, [otherNode]); | ||
} | ||
function NodeTextContentSetter(node, textContent) { | ||
ReflectApply(NodeProtoTextContentSetter, node, [textContent]); | ||
} | ||
const { attachShadow: ElementProtoAttachShadow, getAttributeNode: ElementProtoGetAttributeNode, getAttributeNodeNS: ElementProtoGetAttributeNodeNS, insertAdjacentHTML: ElementProtoInsertAdjacentHTML, querySelector: ElementProtoQuerySelector, removeAttributeNode: ElementProtoRemoveAttributeNode, setAttribute: ElementProtoSetAttribute, setAttributeNS: ElementProtoSetAttributeNS, setAttributeNodeNS: ElementProtoSetAttributeNodeNS, setAttributeNode: ElementProtoSetAttributeNode, } = Element.prototype; | ||
const ElementProtoInnerHTMLSetter = ObjectLookupOwnSetter(Element.prototype, 'innerHTML'); | ||
const ElementProtoOuterHTMLSetter = ObjectLookupOwnSetter(Element.prototype, 'outerHTML'); | ||
const ElementProtoAttributesGetter = ObjectLookupOwnGetter(Element.prototype, 'attributes'); | ||
function ElementInnerHTMLSetter(el, html) { | ||
ReflectApply(ElementProtoInnerHTMLSetter, el, [html]); | ||
} | ||
function ElementOuterHTMLGetter(el) { | ||
return ReflectApply(ElementProtoOuterHTMLGetter, el, emptyArray); | ||
} | ||
function ElementOuterHTMLSetter(el, html) { | ||
@@ -93,6 +113,39 @@ ReflectApply(ElementProtoOuterHTMLSetter, el, [html]); | ||
const HTMLTemplateElementProtoContentGetter = ObjectLookupOwnGetter(HTMLTemplateElement.prototype, 'content'); | ||
function HTMLTemplateElementContentGetter(templateEl) { | ||
return ReflectApply(HTMLTemplateElementProtoContentGetter, templateEl, emptyArray); | ||
function HTMLTemplateElementContentGetter(template) { | ||
return ReflectApply(HTMLTemplateElementProtoContentGetter, template, emptyArray); | ||
} | ||
const { appendChild: NodeProtoAppendChild, cloneNode: NodeProtoCloneNode, isEqualNode: NodeProtoIsEqualNode, } = Node.prototype; | ||
const NodeProtoChildNodesGetter = ObjectLookupOwnGetter(Node.prototype, 'childNodes'); | ||
const NodeProtoFirstChildGetter = ObjectLookupOwnGetter(Node.prototype, 'firstChild'); | ||
const NodeProtoNodeNameGetter = ObjectLookupOwnGetter(Node.prototype, 'nodeName'); | ||
const NodeProtoOwnerDocumentGetter = ObjectLookupOwnGetter(Node.prototype, 'ownerDocument'); | ||
const NodeProtoTextContentSetter = ObjectLookupOwnSetter(Node.prototype, 'textContent'); | ||
function NodeAppendChild(node, childNode) { | ||
return ReflectApply(NodeProtoAppendChild, node, [childNode]); | ||
} | ||
function NodeChildNodesGetter(node) { | ||
return ReflectApply(NodeProtoChildNodesGetter, node, emptyArray); | ||
} | ||
function NodeClone(node, deep = false) { | ||
return ReflectApply(NodeProtoCloneNode, node, [deep]); | ||
} | ||
function NodeFirstChildGetter(node) { | ||
return ReflectApply(NodeProtoFirstChildGetter, node, emptyArray); | ||
} | ||
function NodeIsEqualNode(node, otherNode) { | ||
return ReflectApply(NodeProtoIsEqualNode, node, [otherNode]); | ||
} | ||
function NodeNameGetter(node) { | ||
// Normalize nodeName to upper case. | ||
// See https://johnresig.com/blog/nodename-case-sensitivity/. | ||
return StringToUpperCase(ReflectApply(NodeProtoNodeNameGetter, node, emptyArray)); | ||
} | ||
function NodeOwnerDocumentGetter(node) { | ||
return ReflectApply(NodeProtoOwnerDocumentGetter, node, emptyArray); | ||
} | ||
function NodeTextContentSetter(node, textContent) { | ||
ReflectApply(NodeProtoTextContentSetter, node, [textContent]); | ||
} | ||
const { document } = window; | ||
@@ -132,24 +185,2 @@ const leftTpl = DocumentCreateElement(document, 'template'); | ||
const AttrProtoValueDescriptor = ReflectGetOwnPropertyDescriptor(Attr.prototype, 'value'); | ||
const AttrProtoNameGetter = ObjectLookupOwnGetter(Attr.prototype, 'name'); | ||
const AttrProtoNamespaceURIGetter = ObjectLookupOwnGetter(Attr.prototype, 'namespaceURI'); | ||
const AttrProtoOwnerElementGetter = ObjectLookupOwnGetter(Attr.prototype, 'ownerElement'); | ||
const AttrProtoValueGetter = AttrProtoValueDescriptor.get; | ||
const AttrProtoValueSetter = AttrProtoValueDescriptor.set; | ||
function AttrNameGetter(attr) { | ||
return ReflectApply(AttrProtoNameGetter, attr, emptyArray); | ||
} | ||
function AttrNamespaceURIGetter(attr) { | ||
return ReflectApply(AttrProtoNamespaceURIGetter, attr, emptyArray); | ||
} | ||
function AttrOwnerElementGetter(attr) { | ||
return ReflectApply(AttrProtoOwnerElementGetter, attr, emptyArray); | ||
} | ||
function AttrValueGetter(attr) { | ||
return ReflectApply(AttrProtoValueGetter, attr, emptyArray); | ||
} | ||
function AttrValueSetter(attr, value) { | ||
ReflectApply(AttrProtoValueSetter, attr, [value]); | ||
} | ||
const BlobProtoSizeGetter = ObjectLookupOwnGetter(Blob.prototype, 'size'); | ||
@@ -166,3 +197,3 @@ const { slice: BlobProtoSlice } = Blob.prototype; | ||
function BlobTypeGetter(blob) { | ||
return ReflectApply(BlobProtoTypeGetter, blob, emptyArray); | ||
return StringToLowerCase(ReflectApply(BlobProtoTypeGetter, blob, emptyArray)); | ||
} | ||
@@ -176,3 +207,3 @@ | ||
const { define: CustomElementRegistryDefineValue, get: CustomElementRegistryGet, } = CustomElementRegistry.prototype; | ||
const { define: CustomElementRegistryProtoDefine, get: CustomElementRegistryProtoGet, } = CustomElementRegistry.prototype; | ||
@@ -185,10 +216,15 @@ const { getElementById: DocumentFragmentProtoGetElementById } = DocumentFragment.prototype; | ||
const DOMTokenListProtoValueGetter = ObjectLookupOwnGetter(DOMTokenList.prototype, 'value'); | ||
function DOMTokenListValueGetter(tokenList) { | ||
return ReflectApply(DOMTokenListProtoValueGetter, tokenList, emptyArray); | ||
} | ||
const HTMLElementProtoDatasetGetter = ObjectLookupOwnGetter(HTMLElement.prototype, 'dataset'); | ||
const HTMLElementProtoStyleGetter = ObjectLookupOwnGetter(HTMLElement.prototype, 'style'); | ||
const HTMLElementProtoInnerTextSetter = ObjectLookupOwnSetter(HTMLElement.prototype, 'innerText'); | ||
const HTMLElementProtoOuterTextSetter = ObjectLookupOwnSetter(HTMLElement.prototype, 'outerText'); | ||
const { addEventListener: EventTargetProtoAddEventListener } = EventTarget.prototype; | ||
function EventTargetAddEventListener(target, ...args) { | ||
return ReflectApply(EventTargetProtoAddEventListener, target, args); | ||
} | ||
const HTMLAnchorElementProtoHostnameGetter = ObjectLookupOwnGetter(HTMLAnchorElement.prototype, 'hostname'); | ||
const { get: HTMLAnchorElementProtoHrefGetter, set: HTMLAnchorElementProtoHrefSetter, } = ReflectGetOwnPropertyDescriptor(HTMLAnchorElement.prototype, 'href'); | ||
const HTMLAnchorElementProtoHostnameGetter = ObjectLookupOwnGetter(HTMLAnchorElement.prototype, 'hostname'); | ||
const HTMLAnchorElementProtoPathnameGetter = ObjectLookupOwnGetter(HTMLAnchorElement.prototype, 'pathname'); | ||
const HTMLAnchorElementProtoProtocolGetter = ObjectLookupOwnGetter(HTMLAnchorElement.prototype, 'protocol'); | ||
function HTMLAnchorElementHostnameGetter(anchor) { | ||
@@ -203,3 +239,31 @@ return ReflectApply(HTMLAnchorElementProtoHostnameGetter, anchor, emptyArray); | ||
} | ||
function HTMLAnchorElementPathnameGetter(anchor) { | ||
return ReflectApply(HTMLAnchorElementProtoPathnameGetter, anchor, emptyArray); | ||
} | ||
function HTMLAnchorElementProtocolGetter(anchor) { | ||
return ReflectApply(HTMLAnchorElementProtoProtocolGetter, anchor, emptyArray); | ||
} | ||
// The innerText and outerText setters may be undefined. | ||
const HTMLElementProtoInnerTextSetter = ObjectLookupOwnSetter(HTMLElement.prototype, 'innerText'); | ||
const HTMLElementProtoOuterTextSetter = ObjectLookupOwnSetter(HTMLElement.prototype, 'outerText'); | ||
const HTMLElementProtoDatasetGetter = ObjectLookupOwnGetter(HTMLElement.prototype, 'dataset'); | ||
const HTMLElementProtoStyleGetter = ObjectLookupOwnGetter(HTMLElement.prototype, 'style'); | ||
function HTMLElementDatasetGetter(el) { | ||
return ReflectApply(HTMLElementProtoDatasetGetter, el, emptyArray); | ||
} | ||
const HTMLElementInnerTextSetter = HTMLElementProtoInnerTextSetter | ||
? function HTMLElementInnerTextSetter(el, text) { | ||
ReflectApply(HTMLElementProtoInnerTextSetter, el, [text]); | ||
} | ||
: function HTMLElementInnerTextSetter(_el, _text) { }; | ||
const HTMLElementOuterTextSetter = HTMLElementProtoOuterTextSetter | ||
? function HTMLElementOuterTextSetter(el, text) { | ||
ReflectApply(HTMLElementProtoOuterTextSetter, el, [text]); | ||
} | ||
: function HTMLElementOuterTextSetter(_el, _text) { }; | ||
function HTMLElementStyleGetter(el) { | ||
return ReflectApply(HTMLElementProtoStyleGetter, el, emptyArray); | ||
} | ||
const HTMLFrameElementProtoContentWindowGetter = ObjectLookupOwnGetter(HTMLFrameElement.prototype, 'contentWindow'); | ||
@@ -211,9 +275,18 @@ function HTMLFrameElementContentWindowGetter(frame) { | ||
const HTMLIFrameElementProtoContentWindowGetter = ObjectLookupOwnGetter(HTMLIFrameElement.prototype, 'contentWindow'); | ||
const HTMLIframeElementProtoSrcSetter = ObjectLookupOwnSetter(HTMLIFrameElement.prototype, 'src'); | ||
function HTMLIframeElementContentWindowGetter(iframe) { | ||
const HTMLIFrameElementProtoSrcSetter = ObjectLookupOwnSetter(HTMLIFrameElement.prototype, 'src'); | ||
function HTMLIFrameElementContentWindowGetter(iframe) { | ||
return ReflectApply(HTMLIFrameElementProtoContentWindowGetter, iframe, emptyArray); | ||
} | ||
function HTMLIFrameElementSrcSetter(iframe, src) { | ||
ReflectApply(HTMLIFrameElementProtoSrcSetter, iframe, [src]); | ||
} | ||
const HTMLLinkElementProtoRelSetter = ObjectLookupOwnSetter(HTMLLinkElement.prototype, 'rel'); | ||
const HTMLLinkElementProtoRelListSetter = ObjectLookupOwnSetter(HTMLLinkElement.prototype, 'relList'); | ||
function HTMLLinkElementRelSetter(link, rel) { | ||
ReflectApply(HTMLLinkElementProtoRelSetter, link, [rel]); | ||
} | ||
function HTMLLinkElementRelListSetter(link, relList) { | ||
ReflectApply(HTMLLinkElementProtoRelListSetter, link, [relList]); | ||
} | ||
@@ -229,9 +302,7 @@ const HTMLObjectProtoContentWindowGetter = ObjectLookupOwnGetter(HTMLObjectElement.prototype, 'contentWindow'); | ||
const HTMLScriptElementProtoSrcDescriptor = ReflectGetOwnPropertyDescriptor(HTMLScriptElement.prototype, 'src'); | ||
const HTMLScriptElementProtoSrcGetter = HTMLScriptElementProtoSrcDescriptor.get; | ||
const HTMLScriptElementProtoSrcSetter = HTMLScriptElementProtoSrcDescriptor.set; | ||
const { get: HTMLScriptElementProtoSrcGetter, set: HTMLScriptElementProtoSrcSetter, } = ReflectGetOwnPropertyDescriptor(HTMLScriptElement.prototype, 'src'); | ||
const MessageEventProtoSourceGetter = ObjectLookupOwnGetter(MessageEvent.prototype, 'source'); | ||
function MessageEventSourceGetter(messageEvt) { | ||
return ReflectApply(MessageEventProtoSourceGetter, messageEvt, emptyArray); | ||
function MessageEventSourceGetter(messageEvent) { | ||
return ReflectApply(MessageEventProtoSourceGetter, messageEvent, emptyArray); | ||
} | ||
@@ -251,8 +322,14 @@ | ||
const SVGElementProtoDatasetGetter = ObjectLookupOwnGetter(SVGElement.prototype, 'dataset'); | ||
function SVGElementDatasetGetter(svg) { | ||
return ReflectApply(SVGElementProtoDatasetGetter, svg, emptyArray); | ||
} | ||
const { createObjectURL: URLCreateObjectURL, revokeObjectURL: URLRevokeObjectURL } = URL; | ||
const allowlistPatched = ['opener', 'parent']; | ||
const allowListRaw = ['close', 'closed', 'focus', 'postMessage']; | ||
const { clearInterval: WindowStaticClearInterval, setInterval: WindowStaticSetInterval } = window; | ||
const ALLOW_LIST_PATCHED = ['opener', 'parent']; | ||
const ALLOW_LIST_RAW = ['close', 'closed', 'focus', 'postMessage']; | ||
const { clearInterval: WindowStaticClearInterval } = window; | ||
const WindowStaticOpenerGetter = ObjectLookupOwnGetter(window, 'opener'); | ||
const WindowStaticParentGetter = ObjectLookupOwnGetter(window, 'parent'); | ||
const WindowStaticSelfGetter = ObjectLookupOwnGetter(window, 'self'); | ||
function bind(func, context) { | ||
@@ -264,9 +341,9 @@ const bound = FunctionBind(func, context); | ||
const patchedWindowMap = new WeakMapCtor(); | ||
// setInterval and clearInterval are part of WindowOrGlobalScope mixin, they do | ||
// not belong on a prototype https://developer.mozilla.org/en-US/docs/Web/API/WindowOrWorkerGlobalScope | ||
const { encodeURIComponent: WindowStaticEncodeURIComponent, fetch: WindowStaticFetch, open: WindowStaticOpen, } = window; | ||
// setInterval and clearInterval are part of WindowOrGlobalScope mixin, they are | ||
// not on Window.prototype. See https://developer.mozilla.org/en-US/docs/Web/API/WindowOrWorkerGlobalScope. | ||
const { decodeURIComponent: WindowStaticDecodeURIComponent, encodeURIComponent: WindowStaticEncodeURIComponent, fetch: WindowStaticFetch, open: WindowStaticOpen, setInterval: WindowStaticSetInterval, setTimeout: WindowStaticSetTimeout, } = window; | ||
function createPatchedWindow(rawWindow) { | ||
const patchedWindow = {}; | ||
for (let i = 0, len = allowListRaw.length; i < len; i += 1) { | ||
const key = allowListRaw[i]; | ||
for (let i = 0, len = ALLOW_LIST_RAW.length; i < len; i += 1) { | ||
const key = ALLOW_LIST_RAW[i]; | ||
const originalDescriptor = ReflectGetOwnPropertyDescriptor(rawWindow, key); | ||
@@ -289,4 +366,4 @@ if (originalDescriptor) { | ||
} | ||
for (let i = 0, len = allowlistPatched.length; i < len; i += 1) { | ||
const key = allowlistPatched[i]; | ||
for (let i = 0, len = ALLOW_LIST_PATCHED.length; i < len; i += 1) { | ||
const key = ALLOW_LIST_PATCHED[i]; | ||
const patchedDescriptor = ObjectCreate(null); | ||
@@ -322,22 +399,62 @@ const originalDescriptor = ReflectGetOwnPropertyDescriptor(rawWindow, key); | ||
} | ||
function WindowOpenerGetter(win) { | ||
return ReflectApply(WindowStaticOpenerGetter, win, emptyArray); | ||
} | ||
function WindowParentGetter(win) { | ||
return ReflectApply(WindowStaticParentGetter, win, emptyArray); | ||
} | ||
function WindowSelfGetter(win) { | ||
return ReflectApply(WindowStaticSelfGetter, win, emptyArray); | ||
} | ||
function WindowSetInterval(win, ...args) { | ||
return ReflectApply(WindowStaticSetInterval, win, args); | ||
} | ||
function isWindowLike(value) { | ||
// fast check to narrow down when to do the slow check for window objects | ||
// window.top is unforgeable, this means this check should be safe from | ||
// user-intervention to try to bypass this check. | ||
return ObjectHasOwnProperty(value, 'top'); | ||
} | ||
function isWindow(value) { | ||
// slower check that must certainly detect a window object | ||
try { | ||
// window.self getter only works for a window object, otherwise it throws, | ||
// additionally, this works fine for a detached window as well, which is | ||
// important since it will guarantee that this check works also for iframes | ||
// that are disconnected, and could be connected later on, that should not | ||
// bypass this check. This check is is also equivalent to window.frames, and | ||
// here is the very simple spec for this getter: | ||
// https://html.spec.whatwg.org/multipage/window-object.html#dom-self | ||
WindowSelfGetter(value); | ||
return true; | ||
// eslint-disable-next-line no-empty | ||
} | ||
catch (_a) { } | ||
return false; | ||
} | ||
const XhrCtor = XMLHttpRequest; | ||
const XhrProto = XhrCtor.prototype; | ||
const { open: XhrProtoOpen, send: XhrProtoSend } = XhrProto; | ||
const XhrOnReadyStateChangeSetter = ObjectLookupOwnSetter(XhrProto, 'onreadystatechange'); | ||
const XhrReadyStateGetter = ObjectLookupOwnGetter(XhrProto, 'readyState'); | ||
const XhrResponseTextGetter = ObjectLookupOwnGetter(XhrProto, 'responseText'); | ||
const XhrStatusGetter = ObjectLookupOwnGetter(XhrProto, 'status'); | ||
const XhrWithCredentialsSetter = ObjectLookupOwnSetter(XhrProto, 'withCredentials'); | ||
const { send: XhrProtoSend } = XhrProto; | ||
const XhrProtoResponseTextGetter = ObjectLookupOwnGetter(XhrProto, 'responseText'); | ||
const XhrProtoStatusGetter = ObjectLookupOwnGetter(XhrProto, 'status'); | ||
const XhrProtoWithCredentialsSetter = ObjectLookupOwnSetter(XhrProto, 'withCredentials'); | ||
const { open: XhrProtoOpen } = XhrProto; | ||
function XhrOpen(xhr, requestMethod, url, async = true) { | ||
return ReflectApply(XhrProtoOpen, xhr, [requestMethod, url, async]); | ||
} | ||
function XhrResponseTextGetter(xhr) { | ||
return ReflectApply(XhrProtoResponseTextGetter, xhr, emptyArray); | ||
} | ||
function XhrSend(xhr) { | ||
return ReflectApply(XhrProtoSend, xhr, emptyArray); | ||
} | ||
function XhrStatusGetter(xhr) { | ||
return ReflectApply(XhrProtoStatusGetter, xhr, emptyArray); | ||
} | ||
function XhrWithCredentialsSetter(xhr, bool) { | ||
ReflectApply(XhrProtoWithCredentialsSetter, xhr, [bool]); | ||
} | ||
export { AttrNameGetter, AttrNamespaceURIGetter, AttrOwnerElementGetter, AttrProtoNameGetter, AttrProtoNamespaceURIGetter, AttrProtoOwnerElementGetter, AttrProtoValueGetter, AttrProtoValueSetter, AttrValueGetter, AttrValueSetter, BlobCtor, BlobSizeGetter, BlobSlice, BlobTypeGetter, CookieStoreProtoDelete, CookieStoreProtoGet, CookieStoreProtoGetAll, CookieStoreProtoSet, CustomElementRegistryDefineValue, CustomElementRegistryGet, DOMTokenListProtoValueGetter, DocumentBodyGetter, DocumentCookieGetter, DocumentCookieSetter, DocumentCreateElement, DocumentFragmentGetElementById, DocumentGetElementById, DocumentHeadGetter, DocumentProtoBodyGetter, DocumentProtoCreateElement, DocumentProtoExecCommand, DocumentProtoGetElementById, DocumentProtoHeadGetter, ElementAttributesGetter, ElementGetAttributeNode, ElementGetAttributeNodeNS, ElementInnerHTMLSetter, ElementOuterHTMLSetter, ElementProtoAttachShadow, ElementProtoGetAttributeNode, ElementProtoGetAttributeNodeNS, ElementProtoInsertAdjacentHTML, ElementProtoQuerySelector, ElementProtoRemoveAttributeNode, ElementProtoSetAttribute, ElementProtoSetAttributeNS, ElementProtoSetAttributeNode, ElementProtoSetAttributeNodeNS, ElementQuerySelector, ElementRemoveAttributeNode, ElementSetAttribute, ElementSetAttributeNS, ElementSetAttributeNode, ElementSetAttributeNodeNS, HTMLAnchorElementHostnameGetter, HTMLAnchorElementHrefGetter, HTMLAnchorElementHrefSetter, HTMLElementProtoDatasetGetter, HTMLElementProtoInnerTextSetter, HTMLElementProtoOuterTextSetter, HTMLElementProtoStyleGetter, HTMLFrameElementContentWindowGetter, HTMLIframeElementContentWindowGetter, HTMLIframeElementProtoSrcSetter, HTMLLinkElementProtoRelListSetter, HTMLLinkElementProtoRelSetter, HTMLObjectElementContentWindowGetter, HTMLScriptElementProtoSrcGetter, HTMLScriptElementProtoSrcSetter, MessageEventSourceGetter, NamedNodeMapProtoSetNamedItem, NodeAppendChild, NodeChildNodesGetter, NodeIsEqualNode, NodeProtoNodeNameGetter, NodeTextContentSetter, RangeProtoCreateContextualFragment, RequestURLGetter, SVGElementProtoDatasetGetter, StorageProtoGetItem, StorageProtoKey, StorageProtoRemoveItem, StorageProtoSetItem, URLCreateObjectURL, URLRevokeObjectURL, WindowClearInterval, WindowSetInterval, WindowStaticEncodeURIComponent, WindowStaticFetch, WindowStaticOpen, XhrCtor, XhrOnReadyStateChangeSetter, XhrOpen, XhrProtoOpen, XhrProtoSend, XhrReadyStateGetter, XhrResponseTextGetter, XhrSend, XhrStatusGetter, XhrWithCredentialsSetter, createPatchedWindow, isEqualDomString, isSharedElement, nsCookieKey, nsCookieRootKey, patchedWindowMap }; | ||
/** version: 0.13.5 */ | ||
export { AttrNameGetter, AttrNamespaceURIGetter, AttrOwnerElementGetter, AttrValueGetter, AttrValueSetter, BlobCtor, BlobSizeGetter, BlobSlice, BlobTypeGetter, CookieStoreProtoDelete, CookieStoreProtoGet, CookieStoreProtoGetAll, CookieStoreProtoSet, CustomElementRegistryProtoDefine, CustomElementRegistryProtoGet, DOMTokenListValueGetter, DocumentBodyGetter, DocumentCookieGetter, DocumentCookieSetter, DocumentCreateComment, DocumentCreateElement, DocumentCreateElementNS, DocumentFragmentGetElementById, DocumentGetElementById, DocumentHeadGetter, DocumentProtoExecCommand, ElementAttributesGetter, ElementClosest, ElementGetAttributeNode, ElementGetAttributeNodeNS, ElementInnerHTMLGetter, ElementInnerHTMLSetter, ElementOuterHTMLGetter, ElementOuterHTMLSetter, ElementProtoAttachShadow, ElementProtoInsertAdjacentHTML, ElementProtoSetAttribute, ElementProtoSetAttributeNS, ElementProtoSetAttributeNode, ElementQuerySelector, ElementRemoveAttributeNode, ElementSetAttribute, ElementSetAttributeNS, ElementSetAttributeNode, ElementSetAttributeNodeNS, EventTargetAddEventListener, HTMLAnchorElementHostnameGetter, HTMLAnchorElementHrefGetter, HTMLAnchorElementHrefSetter, HTMLAnchorElementPathnameGetter, HTMLAnchorElementProtocolGetter, HTMLElementDatasetGetter, HTMLElementInnerTextSetter, HTMLElementOuterTextSetter, HTMLElementStyleGetter, HTMLFrameElementContentWindowGetter, HTMLIFrameElementContentWindowGetter, HTMLIFrameElementSrcSetter, HTMLLinkElementRelListSetter, HTMLLinkElementRelSetter, HTMLObjectElementContentWindowGetter, HTMLScriptElementProtoSrcGetter, HTMLScriptElementProtoSrcSetter, HTMLTemplateElementContentGetter, MessageEventSourceGetter, NamedNodeMapProtoSetNamedItem, NodeAppendChild, NodeChildNodesGetter, NodeClone, NodeFirstChildGetter, NodeIsEqualNode, NodeNameGetter, NodeOwnerDocumentGetter, NodeTextContentSetter, RangeProtoCreateContextualFragment, RequestURLGetter, SVGElementDatasetGetter, StorageProtoGetItem, StorageProtoKey, StorageProtoRemoveItem, StorageProtoSetItem, URLCreateObjectURL, URLRevokeObjectURL, WindowClearInterval, WindowOpenerGetter, WindowParentGetter, WindowSelfGetter, WindowSetInterval, WindowStaticDecodeURIComponent, WindowStaticEncodeURIComponent, WindowStaticFetch, WindowStaticOpen, WindowStaticSetInterval, WindowStaticSetTimeout, XhrCtor, XhrOpen, XhrProtoOpen, XhrResponseTextGetter, XhrSend, XhrStatusGetter, XhrWithCredentialsSetter, createPatchedWindow, isEqualDomString, isSharedElement, isWindow, isWindowLike, nsCookieKey, nsCookieRootKey, patchedWindowMap }; | ||
/** version: 0.13.6 */ |
{ | ||
"name": "@locker/shared-dom", | ||
"version": "0.13.5", | ||
"version": "0.13.6", | ||
"license": "Salesforce Developer Agreement", | ||
@@ -13,6 +13,2 @@ "author": "Salesforce UI Security Team", | ||
}, | ||
"files": [ | ||
"dist/", | ||
"types/" | ||
], | ||
"scripts": { | ||
@@ -23,5 +19,9 @@ "build": "tsc --project tsconfig.types.json && rollup --config .rolluprc.cjs", | ||
"dependencies": { | ||
"@locker/shared": "0.13.5" | ||
"@locker/shared": "0.13.6" | ||
}, | ||
"gitHead": "213b7ea798dd4a01891a5b5ead2cff46f6db5600" | ||
"files": [ | ||
"dist/", | ||
"types/" | ||
], | ||
"gitHead": "c323e27d3a3d5767725b338c81f9e24cb59cbc6f" | ||
} |
@@ -1,6 +0,1 @@ | ||
export declare const AttrProtoNameGetter: Function; | ||
export declare const AttrProtoNamespaceURIGetter: Function; | ||
export declare const AttrProtoOwnerElementGetter: Function; | ||
export declare const AttrProtoValueGetter: () => any; | ||
export declare const AttrProtoValueSetter: (v: any) => void; | ||
export declare function AttrNameGetter(attr: Attr): typeof Attr.prototype.name; | ||
@@ -7,0 +2,0 @@ export declare function AttrNamespaceURIGetter(attr: Attr): typeof Attr.prototype.namespaceURI; |
@@ -6,4 +6,4 @@ export declare const BlobCtor: { | ||
export declare function BlobSizeGetter(blob: Blob): typeof Blob.prototype.size; | ||
export declare function BlobSlice(blob: Blob, ...args: any[]): ReturnType<typeof Blob.prototype.slice>; | ||
export declare function BlobSlice(blob: Blob, ...args: Parameters<typeof Blob.prototype.slice>): ReturnType<typeof Blob.prototype.slice>; | ||
export declare function BlobTypeGetter(blob: Blob): typeof Blob.prototype.type; | ||
//# sourceMappingURL=Blob.d.ts.map |
@@ -1,2 +0,2 @@ | ||
export declare const CustomElementRegistryDefineValue: (name: string, constructor: CustomElementConstructor, options?: ElementDefinitionOptions | undefined) => void, CustomElementRegistryGet: (name: string) => any; | ||
export declare const CustomElementRegistryProtoDefine: (name: string, constructor: CustomElementConstructor, options?: ElementDefinitionOptions | undefined) => void, CustomElementRegistryProtoGet: (name: string) => any; | ||
//# sourceMappingURL=CustomElementRegistry.d.ts.map |
@@ -1,16 +0,12 @@ | ||
export declare const DocumentProtoCreateElement: { | ||
<K extends "object" | "link" | "small" | "sub" | "sup" | "track" | "progress" | "a" | "abbr" | "address" | "applet" | "area" | "article" | "aside" | "audio" | "b" | "base" | "basefont" | "bdi" | "bdo" | "blockquote" | "body" | "br" | "button" | "canvas" | "caption" | "cite" | "code" | "col" | "colgroup" | "data" | "datalist" | "dd" | "del" | "details" | "dfn" | "dialog" | "dir" | "div" | "dl" | "dt" | "em" | "embed" | "fieldset" | "figcaption" | "figure" | "font" | "footer" | "form" | "frame" | "frameset" | "h1" | "h2" | "h3" | "h4" | "h5" | "h6" | "head" | "header" | "hgroup" | "hr" | "html" | "i" | "iframe" | "img" | "input" | "ins" | "kbd" | "label" | "legend" | "li" | "main" | "map" | "mark" | "marquee" | "menu" | "meta" | "meter" | "nav" | "noscript" | "ol" | "optgroup" | "option" | "output" | "p" | "param" | "picture" | "pre" | "q" | "rp" | "rt" | "ruby" | "s" | "samp" | "script" | "section" | "select" | "slot" | "source" | "span" | "strong" | "style" | "summary" | "table" | "tbody" | "td" | "template" | "textarea" | "tfoot" | "th" | "thead" | "time" | "title" | "tr" | "u" | "ul" | "var" | "video" | "wbr">(tagName: K, options?: ElementCreationOptions | undefined): HTMLElementTagNameMap[K]; | ||
<K_1 extends "listing" | "xmp">(tagName: K_1, options?: ElementCreationOptions | undefined): HTMLElementDeprecatedTagNameMap[K_1]; | ||
(tagName: string, options?: ElementCreationOptions | undefined): HTMLElement; | ||
}, DocumentProtoExecCommand: (commandId: string, showUI?: boolean | undefined, value?: string | undefined) => boolean, DocumentProtoGetElementById: (elementId: string) => HTMLElement | null; | ||
export declare const DocumentProtoBodyGetter: Function; | ||
export declare const DocumentProtoHeadGetter: Function; | ||
export declare const DocumentProtoExecCommand: (commandId: string, showUI?: boolean | undefined, value?: string | undefined) => boolean; | ||
export declare function DocumentBodyGetter(doc: Document): typeof Document.prototype.body; | ||
export declare function DocumentCookieGetter(doc: Document): typeof Document.prototype.cookie; | ||
export declare function DocumentCookieSetter(doc: Document, newCookie: string): void; | ||
export declare function DocumentCreateElement(doc: Document, ...args: any[]): ReturnType<typeof Document.prototype.createElement>; | ||
export declare function DocumentCreateComment(doc: Document, data?: string): ReturnType<typeof Document.prototype.createComment>; | ||
export declare function DocumentCreateElement(doc: Document, ...args: Parameters<typeof Document.prototype.createElement>): ReturnType<typeof Document.prototype.createElement>; | ||
export declare function DocumentCreateElementNS(doc: Document, ...args: Parameters<typeof Document.prototype.createElementNS>): ReturnType<typeof Document.prototype.createElementNS>; | ||
export declare function DocumentGetElementById(doc: Document, id: string): ReturnType<typeof Document.prototype.getElementById>; | ||
export declare function DocumentHeadGetter(doc: Document): typeof Document.prototype.head; | ||
export declare function nsCookieKey(key: string, ns: string): string; | ||
export declare function nsCookieRootKey(ns: string): string; | ||
export declare function nsCookieKey(key: string, ns: string): string; | ||
//# sourceMappingURL=Document.d.ts.map |
@@ -1,2 +0,2 @@ | ||
export declare const DOMTokenListProtoValueGetter: Function; | ||
export declare function DOMTokenListValueGetter(tokenList: DOMTokenList): typeof DOMTokenList.prototype.value; | ||
//# sourceMappingURL=DOMTokenList.d.ts.map |
@@ -1,7 +0,6 @@ | ||
export declare const ElementProtoAttachShadow: (init: ShadowRootInit) => ShadowRoot, ElementProtoGetAttributeNode: (qualifiedName: string) => Attr | null, ElementProtoGetAttributeNodeNS: (namespace: string | null, localName: string) => Attr | null, ElementProtoInsertAdjacentHTML: (where: InsertPosition, html: string) => void, ElementProtoQuerySelector: { | ||
<K extends "object" | "link" | "small" | "sub" | "sup" | "track" | "progress" | "a" | "abbr" | "address" | "applet" | "area" | "article" | "aside" | "audio" | "b" | "base" | "basefont" | "bdi" | "bdo" | "blockquote" | "body" | "br" | "button" | "canvas" | "caption" | "cite" | "code" | "col" | "colgroup" | "data" | "datalist" | "dd" | "del" | "details" | "dfn" | "dialog" | "dir" | "div" | "dl" | "dt" | "em" | "embed" | "fieldset" | "figcaption" | "figure" | "font" | "footer" | "form" | "frame" | "frameset" | "h1" | "h2" | "h3" | "h4" | "h5" | "h6" | "head" | "header" | "hgroup" | "hr" | "html" | "i" | "iframe" | "img" | "input" | "ins" | "kbd" | "label" | "legend" | "li" | "main" | "map" | "mark" | "marquee" | "menu" | "meta" | "meter" | "nav" | "noscript" | "ol" | "optgroup" | "option" | "output" | "p" | "param" | "picture" | "pre" | "q" | "rp" | "rt" | "ruby" | "s" | "samp" | "script" | "section" | "select" | "slot" | "source" | "span" | "strong" | "style" | "summary" | "table" | "tbody" | "td" | "template" | "textarea" | "tfoot" | "th" | "thead" | "time" | "title" | "tr" | "u" | "ul" | "var" | "video" | "wbr">(selectors: K): HTMLElementTagNameMap[K] | null; | ||
<K_1 extends "symbol" | "a" | "script" | "style" | "title" | "circle" | "clipPath" | "defs" | "desc" | "ellipse" | "feBlend" | "feColorMatrix" | "feComponentTransfer" | "feComposite" | "feConvolveMatrix" | "feDiffuseLighting" | "feDisplacementMap" | "feDistantLight" | "feFlood" | "feFuncA" | "feFuncB" | "feFuncG" | "feFuncR" | "feGaussianBlur" | "feImage" | "feMerge" | "feMergeNode" | "feMorphology" | "feOffset" | "fePointLight" | "feSpecularLighting" | "feSpotLight" | "feTile" | "feTurbulence" | "filter" | "foreignObject" | "g" | "image" | "line" | "linearGradient" | "marker" | "mask" | "metadata" | "path" | "pattern" | "polygon" | "polyline" | "radialGradient" | "rect" | "stop" | "svg" | "switch" | "text" | "textPath" | "tspan" | "use" | "view">(selectors: K_1): SVGElementTagNameMap[K_1] | null; | ||
<E extends Element = Element>(selectors: string): E | null; | ||
}, ElementProtoRemoveAttributeNode: (attr: Attr) => Attr, ElementProtoSetAttribute: (qualifiedName: string, value: string) => void, ElementProtoSetAttributeNS: (namespace: string | null, qualifiedName: string, value: string) => void, ElementProtoSetAttributeNodeNS: (attr: Attr) => Attr | null, ElementProtoSetAttributeNode: (attr: Attr) => Attr | null; | ||
export declare const ElementProtoAttachShadow: (init: ShadowRootInit) => ShadowRoot, ElementProtoInsertAdjacentHTML: (where: InsertPosition, html: string) => void, ElementProtoSetAttribute: (qualifiedName: string, value: string) => void, ElementProtoSetAttributeNS: (namespace: string | null, qualifiedName: string, value: string) => void, ElementProtoSetAttributeNode: (attr: Attr) => Attr | null; | ||
export declare function ElementClosest(el: Element, selectors: string): ReturnType<typeof Element.prototype.closest>; | ||
export declare function ElementInnerHTMLGetter(el: Element): typeof Element.prototype.innerHTML; | ||
export declare function ElementInnerHTMLSetter(el: Element, html: string): void; | ||
export declare function ElementOuterHTMLGetter(el: Element): typeof Element.prototype.outerHTML; | ||
export declare function ElementOuterHTMLSetter(el: Element, html: string): void; | ||
@@ -8,0 +7,0 @@ export declare function ElementQuerySelector(el: Element, selectors: string): ReturnType<typeof Element.prototype.querySelector>; |
export declare function HTMLAnchorElementHostnameGetter(anchor: HTMLAnchorElement): typeof HTMLAnchorElement.prototype.hostname; | ||
export declare function HTMLAnchorElementHrefGetter(anchor: HTMLAnchorElement): typeof HTMLAnchorElement.prototype.href; | ||
export declare function HTMLAnchorElementHrefSetter(anchor: HTMLAnchorElement, href: string): void; | ||
export declare function HTMLAnchorElementPathnameGetter(anchor: HTMLAnchorElement): typeof HTMLAnchorElement.prototype.pathname; | ||
export declare function HTMLAnchorElementProtocolGetter(anchor: HTMLAnchorElement): typeof HTMLAnchorElement.prototype.protocol; | ||
//# sourceMappingURL=HTMLAnchorElement.d.ts.map |
@@ -1,5 +0,5 @@ | ||
export declare const HTMLElementProtoDatasetGetter: Function; | ||
export declare const HTMLElementProtoStyleGetter: Function; | ||
export declare const HTMLElementProtoInnerTextSetter: Function | undefined; | ||
export declare const HTMLElementProtoOuterTextSetter: Function | undefined; | ||
export declare function HTMLElementDatasetGetter(el: HTMLElement): typeof HTMLElement.prototype.dataset; | ||
export declare const HTMLElementInnerTextSetter: (el: HTMLElement, text: string) => void; | ||
export declare const HTMLElementOuterTextSetter: (el: HTMLElement, text: string) => void; | ||
export declare function HTMLElementStyleGetter(el: HTMLElement): typeof HTMLElement.prototype.style; | ||
//# sourceMappingURL=HTMLElement.d.ts.map |
@@ -1,2 +0,3 @@ | ||
export declare function HTMLFrameElementContentWindowGetter(frame: HTMLFrameElement): typeof HTMLFrameElement.prototype.contentWindow; | ||
import { GlobalObject } from './types'; | ||
export declare function HTMLFrameElementContentWindowGetter(frame: HTMLFrameElement): GlobalObject | null; | ||
//# sourceMappingURL=HTMLFrameElement.d.ts.map |
@@ -1,3 +0,3 @@ | ||
export declare const HTMLLinkElementProtoRelSetter: Function; | ||
export declare const HTMLLinkElementProtoRelListSetter: Function; | ||
export declare function HTMLLinkElementRelSetter(link: HTMLLinkElement, rel: string): void; | ||
export declare function HTMLLinkElementRelListSetter(link: HTMLLinkElement, relList: DOMTokenList | string): void; | ||
//# sourceMappingURL=HTMLLinkElement.d.ts.map |
@@ -1,2 +0,3 @@ | ||
export declare const HTMLObjectElementContentWindowGetter: (objectEl: HTMLObjectElement) => typeof HTMLObjectElement.prototype.contentWindow; | ||
import { GlobalObject } from './types'; | ||
export declare const HTMLObjectElementContentWindowGetter: (objectEl: HTMLObjectElement) => GlobalObject | null; | ||
//# sourceMappingURL=HTMLObjectElement.d.ts.map |
@@ -1,3 +0,2 @@ | ||
export declare const HTMLScriptElementProtoSrcGetter: () => any; | ||
export declare const HTMLScriptElementProtoSrcSetter: (v: any) => void; | ||
export declare const HTMLScriptElementProtoSrcGetter: () => any, HTMLScriptElementProtoSrcSetter: (v: any) => void; | ||
//# sourceMappingURL=HTMLScriptElement.d.ts.map |
@@ -0,3 +1,3 @@ | ||
export * from './Attr'; | ||
export * from './basic'; | ||
export * from './Attr'; | ||
export * from './Blob'; | ||
@@ -10,9 +10,11 @@ export * from './CookieStore'; | ||
export * from './Element'; | ||
export * from './EventTarget'; | ||
export * from './HTMLAnchorElement'; | ||
export * from './HTMLElement'; | ||
export * from './HTMLAnchorElement'; | ||
export * from './HTMLFrameElement'; | ||
export * from './HTMLIframeElement'; | ||
export * from './HTMLIFrameElement'; | ||
export * from './HTMLLinkElement'; | ||
export * from './HTMLObjectElement'; | ||
export * from './HTMLScriptElement'; | ||
export * from './HTMLTemplateElement'; | ||
export * from './MessageEvent'; | ||
@@ -25,2 +27,3 @@ export * from './NamedNodeMap'; | ||
export * from './SVGElement'; | ||
export * from './types'; | ||
export * from './URL'; | ||
@@ -27,0 +30,0 @@ export * from './Window'; |
@@ -1,2 +0,2 @@ | ||
export declare function MessageEventSourceGetter(messageEvt: MessageEvent): typeof MessageEvent.prototype.source; | ||
export declare function MessageEventSourceGetter(messageEvent: MessageEvent): typeof MessageEvent.prototype.source; | ||
//# sourceMappingURL=MessageEvent.d.ts.map |
@@ -1,6 +0,9 @@ | ||
export declare const NodeProtoNodeNameGetter: Function; | ||
export declare function NodeAppendChild(node: Node, childNode: ChildNode | DocumentFragment): ReturnType<typeof Node.prototype.appendChild>; | ||
export declare function NodeChildNodesGetter(node: Node): typeof Node.prototype.childNodes; | ||
export declare function NodeClone(node: Node, deep?: boolean): ReturnType<typeof Node.prototype.cloneNode>; | ||
export declare function NodeFirstChildGetter(node: Node): typeof Node.prototype.firstChild; | ||
export declare function NodeIsEqualNode(node: Node, otherNode: Node): ReturnType<typeof Node.prototype.isEqualNode>; | ||
export declare function NodeNameGetter(node: Node): typeof Node.prototype.nodeName; | ||
export declare function NodeOwnerDocumentGetter(node: Node): typeof Node.prototype.ownerDocument; | ||
export declare function NodeTextContentSetter(node: Node, textContent: string): void; | ||
//# sourceMappingURL=Node.d.ts.map |
@@ -1,2 +0,2 @@ | ||
export declare const SVGElementProtoDatasetGetter: Function; | ||
export declare function SVGElementDatasetGetter(svg: SVGElement): typeof SVGElement.prototype.dataset; | ||
//# sourceMappingURL=SVGElement.d.ts.map |
@@ -0,6 +1,12 @@ | ||
import { GlobalObject } from './types'; | ||
export declare const patchedWindowMap: WeakMap<object, any>; | ||
export declare const WindowStaticEncodeURIComponent: typeof encodeURIComponent, WindowStaticFetch: ((input: RequestInfo, init?: RequestInit | undefined) => Promise<Response>) & typeof fetch, WindowStaticOpen: ((url?: string | undefined, target?: string | undefined, features?: string | undefined, replace?: boolean | undefined) => Window | null) & typeof open; | ||
export declare function createPatchedWindow(rawWindow: WindowProxy): Window; | ||
export declare function WindowClearInterval(win: Window, intervalID: number): ReturnType<typeof clearInterval>; | ||
export declare function WindowSetInterval(win: Window, ...args: any[]): number; | ||
export declare const WindowStaticDecodeURIComponent: typeof decodeURIComponent, WindowStaticEncodeURIComponent: typeof encodeURIComponent, WindowStaticFetch: ((input: RequestInfo, init?: RequestInit | undefined) => Promise<Response>) & typeof fetch, WindowStaticOpen: ((url?: string | undefined, target?: string | undefined, features?: string | undefined, replace?: boolean | undefined) => Window | null) & typeof open, WindowStaticSetInterval: ((handler: TimerHandler, timeout?: number | undefined, ...arguments: any[]) => number) & typeof setInterval, WindowStaticSetTimeout: ((handler: TimerHandler, timeout?: number | undefined, ...arguments: any[]) => number) & typeof setTimeout; | ||
export declare function createPatchedWindow(rawWindow: GlobalObject): GlobalObject; | ||
export declare function WindowClearInterval(win: GlobalObject, intervalID: number): ReturnType<typeof window.clearInterval>; | ||
export declare function WindowOpenerGetter(win: GlobalObject): GlobalObject | null; | ||
export declare function WindowParentGetter(win: GlobalObject): GlobalObject; | ||
export declare function WindowSelfGetter(win: GlobalObject): GlobalObject; | ||
export declare function WindowSetInterval(win: GlobalObject, ...args: Parameters<typeof window.setInterval>): number; | ||
export declare function isWindowLike(value: any): value is typeof globalThis; | ||
export declare function isWindow(value: any): value is GlobalObject; | ||
//# sourceMappingURL=Window.d.ts.map |
@@ -13,10 +13,8 @@ export declare const XhrCtor: { | ||
(method: string, url: string, async: boolean, username?: string | null | undefined, password?: string | null | undefined): void; | ||
}, XhrProtoSend: (body?: string | ArrayBuffer | ArrayBufferView | Blob | FormData | URLSearchParams | ReadableStream<Uint8Array> | Document | null | undefined) => void; | ||
export declare const XhrOnReadyStateChangeSetter: Function; | ||
export declare const XhrReadyStateGetter: Function; | ||
export declare const XhrResponseTextGetter: Function; | ||
export declare const XhrStatusGetter: Function; | ||
export declare const XhrWithCredentialsSetter: Function; | ||
}; | ||
export declare function XhrOpen(xhr: XMLHttpRequest, requestMethod: string, url: string, async?: boolean): ReturnType<typeof XMLHttpRequest.prototype.open>; | ||
export declare function XhrResponseTextGetter(xhr: XMLHttpRequest): typeof XMLHttpRequest.prototype.responseText; | ||
export declare function XhrSend(xhr: XMLHttpRequest): ReturnType<typeof XMLHttpRequest.prototype.send>; | ||
export declare function XhrStatusGetter(xhr: XMLHttpRequest): typeof XMLHttpRequest.prototype.status; | ||
export declare function XhrWithCredentialsSetter(xhr: XMLHttpRequest, bool: boolean): void; | ||
//# sourceMappingURL=XMLHttpRequest.d.ts.map |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
82408
17.53%65
6.56%1111
28.14%+ Added
- Removed
Updated