Updating NPM dependencies
This commit is contained in:
397
node_modules/jsdom/Changelog.md
generated
vendored
397
node_modules/jsdom/Changelog.md
generated
vendored
@@ -1,8 +1,305 @@
|
||||
# jsdom Changelog
|
||||
|
||||
<!-- Style guide:
|
||||
|
||||
* Use past tense verbs to start the sentence, e.g. "Fixed", "Added", "Removed", ...
|
||||
* Each bullet point is a sentence (or more), and so ends with a period.
|
||||
* Package names are in `code`, sometimes [`linked`]().
|
||||
* Prefer referring to methods and properties via `someInstance.prop`, instead of `ClassName.prototype.prop`. (Never use `ClassName.prop` except for statics.)
|
||||
* Refer to attributes via `attr=""`.
|
||||
* Refer to elements via `<element>`.
|
||||
* Refer to events via `eventname`.
|
||||
* Refer to CSS properties via `'propname'`.
|
||||
* Never use the IDL terms "interface", "attribute", or "operation".
|
||||
* URL schemes are in `code`, e.g. `data:`.
|
||||
* Except in the headings, all version numbers get a "v" prefix, e.g. v12.2.0.
|
||||
* Follow the bullet point with parenthetical GitHub usernames when contributed by a non-core team member, e.g. "Fixed foo. (person)"
|
||||
|
||||
Other guidelines:
|
||||
|
||||
* Commit messages are primarily for jsdom developers. Changelog entries are primarily for users. Usually you cannot reuse the commit message.
|
||||
* Sometimes a single commit may expand to multiple changelog entries.
|
||||
* Do not include commits that have no user-facing impact, e.g. test rolls, refactorings, benchmark additions, etc.
|
||||
* For regression fixes, note the version in which something regressed.
|
||||
* Breaking changes get their own section.
|
||||
* Group in the order "Added", "Removed", "Changed", "Fixed".
|
||||
* Roughly order changes within those groupings by impact.
|
||||
-->
|
||||
|
||||
## 16.4.0
|
||||
|
||||
* Added a not-implemented warning if you try to use the second pseudo-element argument to `getComputedStyle()`, unless you pass a `::part` or `::slotted` pseudo-element, in which case we throw an error per the spec. (ExE-Boss)
|
||||
* Improved the performance of repeated access to `el.tagName`, which also indirectly improves performance of selector matching and style computation. (eps1lon)
|
||||
* Fixed `form.elements` to respect the `form=""` attribute, so that it can contain non-descendant form controls. (ccwebdesign)
|
||||
* Fixed `el.focus()` to do nothing on disconnected elements. (eps1lon)
|
||||
* Fixed `el.focus()` to work on SVG elements. (zjffun)
|
||||
* Fixed removing the currently-focused element to move focus to the `<body>` element. (eps1lon)
|
||||
* Fixed `imgEl.complete` to return true for `<img>` elements with empty or unset `src=""` attributes. (strager)
|
||||
* Fixed `imgEl.complete` to return true if an error occurs loading the `<img>`, when canvas is enabled. (strager)
|
||||
* Fixed `imgEl.complete` to return false if the `<img>` element's `src=""` attribute is reset. (strager)
|
||||
* Fixed the `valueMissing` validation check for `<input type="radio">`. (zjffun)
|
||||
* Fixed `translate=""` and `draggable=""` attribute processing to use ASCII case-insensitivity, instead of Unicode case-insensitivity. (zjffun)
|
||||
|
||||
## 16.3.0
|
||||
|
||||
* Added firing of `focusin` and `focusout` when using `el.focus()` and `el.blur()`. (trueadm)
|
||||
* Fixed elements with the `contenteditable=""` attribute to be considered as focusable. (jamieliu386)
|
||||
* Fixed `window.NodeFilter` to be per-`Window`, instead of shared across all `Window`s. (ExE-Boss)
|
||||
* Fixed edge-case behavior involving use of objects with `handleEvent` properties as event listeners. (ExE-Boss)
|
||||
* Fixed a second failing image load sometimes firing a `load` event instead of an `error` event, when the `canvas` package is installed. (strager)
|
||||
* Fixed drawing an empty canvas into another canvas. (zjffun)
|
||||
|
||||
## 16.2.2
|
||||
|
||||
* Updated `StyleSheetList` for better spec compliance; notably it no longer inherits from `Array.prototype`. (ExE-Boss)
|
||||
* Fixed `requestAnimationFrame()` from preventing process exit. This likely regressed in v16.1.0.
|
||||
* Fixed `setTimeout()` to no longer leak the closures passed in to it. This likely regressed in v16.1.0. (AviVahl)
|
||||
* Fixed infinite recursion that could occur when calling `click()` on a `<label>` element, or one of its descendants.
|
||||
* Fixed `getComputedStyle()` to consider inline `style=""` attributes. (eps1lon)
|
||||
* Fixed several issues with `<input type="number">`'s `stepUp()` and `stepDown()` functions to be properly decimal-based, instead of floating point-based.
|
||||
* Fixed various issues where updating `selectEl.value` would not invalidate properties such as `selectEl.selectedOptions`. (ExE-Boss)
|
||||
* Fixed `<input>`'s `src` property, and `<ins>`/`<del>`'s `cite` property, to properly reflect as URLs.
|
||||
* Fixed `window.addEventLister`, `window.removeEventListener`, and `window.dispatchEvent` to properly be inherited from `EventTarget`, instead of being distinct functions. (ExE-Boss)
|
||||
* Fixed errors that would occur if attempting to use a DOM object, such as a custom element, as an argument to `addEventListener`.
|
||||
* Fixed errors that would occur when closing a window with outstanding requests to `data:` URLs.
|
||||
* Fixed sporadic issues with the value of `<input type="month">` that could occur in some time zones and for some times.
|
||||
* Fixed `document.implementation.createDocument()` to return an `XMLDocument`, instead of a `Document`. (ExE-Boss)
|
||||
* Fixed running jsdom in a browser to detect globals more reliably. (ExE-Boss)
|
||||
|
||||
## 16.2.1
|
||||
|
||||
* Updated `saxes`, to bring in some BOM-related fixes.
|
||||
* Updated Acorn-related packages to squelch `npm audit` warnings.
|
||||
|
||||
## 16.2.0
|
||||
|
||||
* Added support for custom elements! Congratulations and thanks to [@pmdartus](https://github.com/jsdom/jsdom/commits?author=pmdartus) for making this happen, after ten months of hard work and lots of effort poured into the complex architectural prerequisites in jsdom and supporting packages.
|
||||
* Fixed some issues when trying to use `Attr` as a `Node`, e.g. by checking its `baseURI` property or calling `attr.cloneNode()`.
|
||||
* Fixed a memory leak during parsing that was introduced in v14.0.0.
|
||||
* Fixed edge cases in number/string conversion used for certain element properties that reflected integer attributes.
|
||||
|
||||
## 16.1.0
|
||||
|
||||
* Added `console.timeLog()`.
|
||||
* Changed `Attr` to extend `Node`, to align with specifications. (ExE-Boss)
|
||||
* Changed `<noscript>` children to be parsed as nodes, instead of as text, when `runScripts` is left as the default of `undefined`. (ACHP)
|
||||
* Upgraded `cssstyle` to v2.1.0, which brings along fixes to handling of `rgba()` and `hsl()` colors. (kraynel)
|
||||
* Fixed some selection-related issues when manipulating the value of `<input>`s and `<textarea>`s. (Matthew-Goldberg)
|
||||
* Fixed various issues with `setTimeout()`, `setInterval()`, and `requestAnimationFrame()`, particularly around window closing and recursive calls.
|
||||
|
||||
## 16.0.1
|
||||
|
||||
* Fixed Node v10 and v11 support when `runScripts` was set.
|
||||
* Fixed the behavior when changing an `<input>`'s `type=""` attribute.
|
||||
* Fixed input validation behavior for `<input type="range">` when `max=""` is less than `min=""`.
|
||||
|
||||
## 16.0.0
|
||||
|
||||
For this release we'd like to welcome [@pmdartus](https://github.com/jsdom/jsdom/commits?author=pmdartus) to the core team. Among other work, he's driven the heroic effort of constructor prototype and reform in jsdom and its dependencies over the last few months, to allow us to move away from shared constructors and prototypes, and set the groundwork for custom elements support ([coming soon](https://github.com/jsdom/jsdom/pull/2548)!).
|
||||
|
||||
Breaking changes:
|
||||
|
||||
* Node v10 is now the minimum supported version.
|
||||
* The `dom.runVMScript()` API has been replaced with the more general `dom.getInternalVMContext()` API.
|
||||
* Each jsdom `Window` now creates new instances of all the web platform globals. That is, our old [shared constructor and prototypes](https://github.com/jsdom/jsdom/blob/35894a6703ed1f4de98942780bd99244ac27f600/README.md#shared-constructors-and-prototypes) caveat is no longer in play.
|
||||
* Each jsdom `Window` now exposes all JavaScript-spec-defined globals uniformly. When `runScripts` is disabled, it exposes them as aliases of the ones from the outer Node.js environment. Whereas when `runScripts` is enabled, it exposes fresh copies of each global from the new scripting environment. (Previously, a few typed array classes would always be aliased, and with `runScripts` disabled, the other classes would not be exposed at all.)
|
||||
|
||||
Other changes:
|
||||
|
||||
* Added the `AbstractRange`, `Range`, `StaticRange`, `Selection`, and `window.getSelection()` APIs.
|
||||
* Added working constructors for `Comment`, `Text`, and `DocumentFragment`.
|
||||
* Added `valueAsDate`, `valueAsNumber`, `stepUp()` and `stepDown()` to `<input>` elements. (kraynel)
|
||||
* Added `window.origin`.
|
||||
* Removed `document.origin`.
|
||||
* Fixed `<template>` to work correctly inside XML documents.
|
||||
* Fixed some bugs which would cause jsdom to choose the wrong character encoding because it was failing to detect `<meta charset>` or `<meta http-equiv="charset">` elements.
|
||||
* Fixed `input.type` to default to `"text"`. (connormeredith)
|
||||
* Fixed incorrect validation errors for `<input>` with fractional values for their `step=""` attribute. (kontomondo)
|
||||
* Fixed incorrect validation errors on readonly `<input>` elements.
|
||||
* Fixed `<input type="email" multiple pattern="...">` validation.
|
||||
* Fixed `fileReader.readAsDataURL()` to always base64-encode the result. (ytetsuro)
|
||||
* Fixed inserting `<img>` elements into documents without a browsing context to no longer crash when the `canvas` package is installed.
|
||||
* Fixed a memory leak when using `window.setTimeout()` or `window.setInterval()`.
|
||||
* Improved the performance of `getComputedStyle()`. (eps1lon)
|
||||
|
||||
## 15.2.1
|
||||
|
||||
* Fixed `JSDOM.fromURL()` handling of URLs with hashes in them, to no longer send the hash to the server and append an extra copy of it when constructing the `Document`. (rchl)
|
||||
* Fixed focusing an already-focused element to correctly do nothing, instead of firing additional `focus` events. (eps1lon)
|
||||
* Fixed typo in the not-implemented message for `mediaElement.addTextTrack()`. (mtsmfm)
|
||||
* Upgraded `nwsapi` minimum version to 2.2.0, which fixes issues with `::-webkit-` prefixed pseudo-elements and namespaced attribute selectors.
|
||||
|
||||
## 15.2.0
|
||||
|
||||
* Added basic style inheritance in `getComputedStyle()` for the `'visibility'` property. This sets the foundation for further work on inheritance, cascading, and specificity. (eps1lon)
|
||||
* Added `shadowRoot.activeElement`.
|
||||
* Added `readystatechange` events during document loading.
|
||||
* Added a stub for `form.requestSubmit()`, to match our existing stub for `form.submit()`.
|
||||
* Changed `el.tabIndex`'s default value, when no `tabindex=""` attribute was set, to reflect the updated specification.
|
||||
* Changed the exception thrown by `el.attachShadow()` on something that's already a shadow host, to reflect the updated specification.
|
||||
* Fixed the validation logic for `<input type="range">`.
|
||||
* Fixed `selectEl.value` when no `<option>` is selected to return the empty string, instead of the value of the first option. (tgohn)
|
||||
* Fixed various correctness issues with `new FormData(formElement)`. (brendo)
|
||||
* Fixed error messages when parsing XML to include the filename, instead of using `"undefined"`. (papandreou)
|
||||
* Fixed the logic for reflected properties to not be affected by overwriting of `el.getAttributeNS()` or `el.setAttributeNS()`.
|
||||
* Set `canvas` as an optional ``peerDependency`, which apparently helps with Yarn PnP support.
|
||||
|
||||
## 15.1.1
|
||||
|
||||
* Moved the `nonce` property from `HTMLScriptElement` and `HTMLStyleElement` to `HTMLElement`. Note that it is still just a simple reflection of the attribute, and has not been updated for the rest of the changes in [whatwg/html#2373](https://github.com/whatwg/html/pull/2373).
|
||||
* Fixed the `style` and `on<event>` properties to properly track their related attributes for SVG elements. (kbruneel)
|
||||
* Fixed `XMLHttpRequest` merging preflight and response headers. (thiagohirata)
|
||||
* Fixed `XMLHttpRequest` reserializing `content-type` request headers unnecessarily. See [whatwg/mimesniff#84](https://github.com/whatwg/mimesniff/issues/84) for more details. (thiagohirata)
|
||||
* Fixed `element.tagName` to be the ASCII uppercase of the element's qualified name, instead of the Unicode uppercase.
|
||||
|
||||
## 15.1.0
|
||||
|
||||
* Added the `Headers` class from the Fetch standard.
|
||||
* Added the `element.translate` getter and setter.
|
||||
* Fixed synchronous `XMLHttpRequest` on the newly-released Node.js v12.
|
||||
* Fixed `form.elements` to exclude `<input type="image">` elements.
|
||||
* Fixed event path iteration in shadow DOM cases, following spec fixes at [whatwg/dom#686](https://github.com/whatwg/dom/pull/686) and [whatwg/dom#750](https://github.com/whatwg/dom/pull/750).
|
||||
* Fixed `pattern=""` form control validation to apply the given regular expression to the whole string. (kontomondo)
|
||||
|
||||
## 15.0.0
|
||||
|
||||
Several potentially-breaking changes, each of them fairly unlikely to actually break anything:
|
||||
|
||||
* `JSDOM.fromFile()` now treats `.xht` files as `application/xhtml+xml`, the same as it does for `.xhtml` and `.xml`. Previously, it would treat them as `text/html`.
|
||||
* If the `JSDOM` constructor's `contentType` option has a `charset` parameter, and the first argument to the constructor is a binary data type (e.g. `Buffer` or `ArrayBuffer`), then the `charset` will override any sniffed encoding in the same way as a `Content-Type` header would in browser scenarios. Previously, the `charset` parameter was ignored.
|
||||
* When using the `Blob` or `File` constructor with the `endings: "native"` option, jsdom will now convert line endings to `\n` on all operating systems, for consistency. Previously, on Windows, it would convert line endings to `\r\n`.
|
||||
|
||||
## 14.1.0
|
||||
|
||||
* Added activation behavior for `<a>` and `<area>` elements whose `href=""` points to a `javascript:` URL or fragment.
|
||||
* Added the `<datalist>` element's `options` property.
|
||||
* Added the `<input>` element's `list` property.
|
||||
* Added `PageTransitionEvent`, and the firing of `pageshow` events during loading.
|
||||
* Exposed the `External` class as a property of `window`.
|
||||
* Fixed HTML fragment parsing (via `innerHTML` and `outerHTML`) to be spec-compliant. (pmdartus)
|
||||
* Fixed HTML serialization (e.g. via `innerHTML`) breaking after setting certain properties to non-string values.
|
||||
* Fixed how disabling an element would cause its activation behavior to forever be null, even if it were re-enabled.
|
||||
* Fixed all access to attributes to ignore attributes with namespaces, per the spec.
|
||||
* Fixed `<style>`s to no longer apply to documents without a browsing context. This includes fixing a crash that would occur with such styles if they had an `@import` rule.
|
||||
* Fixed `<option>`'s `label` and `value` properties to return correct values in various edge cases.
|
||||
* Fixed the `load` event during document loading to target the `Document`, not the `Window`.
|
||||
* Fixed the `pretendToBeVisual` option to propagate to child subframes, as well as the main `Window`. (pyrho)
|
||||
* Updated the minimum [`nwsapi`](https://www.npmjs.com/package/nwsapi) version from v2.1.1 to v2.1.3, bringing along a few fixes in our selector engine.
|
||||
|
||||
## 14.0.0
|
||||
|
||||
Breaking changes:
|
||||
|
||||
* `JSDOM.fragment()` now creates fragments whose document has no [browsing context](https://html.spec.whatwg.org/multipage/#concept-document-bc), i.e. no associated `Window`. This means the `defaultView` property will be null, resources will not load, etc.
|
||||
* `JSDOM.fragment()`, called with no arguments, now creates a `DocumentFragment` with no children, instead of with a single child text node whose data was `"undefined"`.
|
||||
|
||||
Other changes:
|
||||
|
||||
* Fixed a regression in v13.2.0 when calling `element.blur()` on a focused element.
|
||||
* Fixed inserting `<link>` elements into documents with no browsing context to no longer crash if the originating `JSDOM` was configured to fetch the resource. Now, per spec, `<link>` elements only attempt to fetch if they are browsing-context connected.
|
||||
* Fixed `<template>` elements to have the correct semantics, of using a separate browsing-context-less document to store its contents. In particular this means resources will not be fetched for elements inside the `<template>`, as per spec.
|
||||
|
||||
## 13.2.0
|
||||
|
||||
* Added support for `MutationObserver`s! (pmdartus)
|
||||
* Added support for XML documents loaded in frames and iframes; previously this would error.
|
||||
* Added the `<progress>` element's `value`, `max`, and `position` properties.
|
||||
* Added `navigator.plugins` and `navigator.mimeTypes`. (But, they are always empty.)
|
||||
* Fixed `<summary>` elements respond to `click` events by toggling their parent `<details>`.
|
||||
* Fixed `<summary>` elements to be focusable.
|
||||
* Fixed XML document DOCTYPE parsing to preserve any custom name values.
|
||||
* Fixed XML documents to default to UTF-8, not windows-1252 like HTML documents do.
|
||||
* Fixed all events fired by jsdom to have `isTrusted` set to `true`.
|
||||
* Fixed `DOMParser`-created documents to have their `readyState` set to `"complete"`.
|
||||
* Fixed how nested `<fieldset>`s get disabled.
|
||||
* Fixed `getComputedStyle()` to throw a sensible exception when passed the wrong argument, instead of one that exposes jsdom internals.
|
||||
* Upgraded our [`saxes`](https://github.com/lddubeau/saxes) dependency, so that it now correctly errors on XML fragments like `<foo bar:="1"/>`.
|
||||
|
||||
## 13.1.0
|
||||
|
||||
* Added `el.insertAdjacentElement()` and `el.insertAdjacentText()`.
|
||||
* Added the firing of a cancelable `reset` event to `form.reset()`. (epfremmer)
|
||||
* Added the `type`, `value`, and `defaultValue` properties to `<output>` elements, including their form reset behavior. (epfremmer)
|
||||
* Added the `outputEl.htmlFor` property.
|
||||
* Fixed the performance of parsing large text nodes, particularly noticeable for large inline `<style>` or `<script>` elements. This regressed in v11.6.0. To learn more, see [V8 issue #6730](https://bugs.chromium.org/p/v8/issues/detail?id=6730#c4).
|
||||
* Fixed the `style` property on `<a>` and `<area>` elements. This regressed in v13.0.0.
|
||||
* Fixed `node.isConnected` to not always return false for nodes inside a shadow tree. (pmdartus)
|
||||
* Fixed `<button type="reset">` and `<input type="reset">` elements to actually perform a form reset when clicked, instead of doing nothing. (epfremmer)
|
||||
* Fixed `el.setCustomValidity()` for `<output>` and `<fieldset>`.
|
||||
* Fixed activation behavior when dispatching bubbling `click` events, so that for example calling `el.click()` on the child of a submit button element will submit the form.
|
||||
* Fixed our XML parsing code to ignore text outside the root element, instead of treating it as an error. (lddubeau)
|
||||
* Fixed XML serialization when elements had an unknown prefix.
|
||||
* Fixed radio button group name matching to be case-sensitive, per [a spec update](https://github.com/whatwg/html/commit/6acdb2122298d2bb7bb839c0a61b4e1f9b0f9bc9).
|
||||
* Fixed `focus`/`blur` events to be composed.
|
||||
* Fixed `mediaElement.duration` to default to `NaN`.
|
||||
* Fixed `olEl.start` to default to `1`.
|
||||
* Fixed using `XMLHttpRequest` against non-existant `file:` URLs to treat that as a network error, instead of crashing. (pascalbayer) Note that in the future we may completely disable `XMLHttpRequest` usage against `file:` URLs to follow the browser security model.
|
||||
* Fixed `document.title` in SVG documents.
|
||||
* Fixed `titleElement.text` to return the child text content, instead of being the same as `titleElement.innerHTML`.
|
||||
* Fixed `<textarea>`s to properly account for child CDATA section nodes changing.
|
||||
* Fixed the value of `Element.prototype[Symbol.unscopables]`.
|
||||
|
||||
## 13.0.0
|
||||
|
||||
Breaking change:
|
||||
|
||||
* Removed support for v1.x of the [`canvas`](https://github.com/Automattic/node-canvas) package, in favor of v2.x. This also removes support for `canvas-prebuilt`, since `canvas` v2.x has a built-in prebuilt version.
|
||||
|
||||
Other changes:
|
||||
|
||||
* Added proper XML serialization, based on the [`w3c-xmlserializer`](https://github.com/jsdom/w3c-xmlserializer) package. Previously we were just using the HTML serialization, even in XML documents.
|
||||
* Added the `storageEvent.initStorageEvent()` method.
|
||||
* Added support for the `passive` option to `addEventListener()`.
|
||||
* Added the `relList` property to `<a>`, `<area>`, and `<link>` elements.
|
||||
* Fixed our implementation of the node tree modification constraints (for example the [ensure pre-insertion validity](https://dom.spec.whatwg.org/#concept-node-ensure-pre-insertion-validity) algorithm). It is no longer possible to add, remove, or move nodes to create impossible DOM trees. (pmdartus)
|
||||
|
||||
## 12.2.0
|
||||
|
||||
* Added support for shadow DOM! This includes shadow roots, slots, composed events, and more. (pmdartus)
|
||||
* Added the `element.toggleAttribute()` method.
|
||||
* Fixed `XMLHttpRequest` sometimes sending an empty request body after a preflight request. (andreasf)
|
||||
* Fixed the `formElement.form` property to use an algorithm that also checks the `form=""` attribute, instead of always looking for the closest ancestor `<form>` element. (jamietre)
|
||||
* Stopped swallowing errors when the `canvas` or `canvas-prebuilt` packages were installed, but failed to load. (joscha)
|
||||
|
||||
## 12.1.0
|
||||
|
||||
* Dramatically upgraded our XML parser, from the unmaintained [`sax`](https://github.com/isaacs/sax-js) package to the well-maintained [`saxes`](https://github.com/lddubeau/saxes) replacement. This increases our specification conformance, including rejecting certain ill-formed XML documents that were previously accepted, and properly handling other constructs like empty comments, CDATA sections, and `<script>` elements. (lddubeau)
|
||||
* Added `fieldsetEl.elements` and `fieldsetEl.type` properties.
|
||||
* Added the `options` parameter to `dom.runVMScript()`. (SimenB)
|
||||
* Added the ability for custom resource loader `fetch()` implementations to see what element initiated the fetch. (sarvaje)
|
||||
* Fixed `input` and `change` events for `<input>` elements to be trusted and uncancelable.
|
||||
* "Fixed" `<script>`s with the `async` attribute to not execute before sync `<script>`s that precede them. We still do not, in general, have proper execution of scripts during the initial parsing of a document, so this fix is more of a reduction of badness than an alignment with the specification. This behavior regressed in v12.0.0. (sarvaje)
|
||||
|
||||
## 12.0.0
|
||||
|
||||
This major release brings along our [new resource loader API](https://github.com/jsdom/jsdom#loading-subresources), finally bringing all the capabilities from jsdom v9 to the new (jsdom v10+) API. Thanks very much to [@sarvaje](https://github.com/sarvaje) for his work to make this possible!
|
||||
|
||||
Breaking changes:
|
||||
|
||||
* jsdom now requires Node.js v8.
|
||||
* Removed the old jsdom API, as the new API now has all the capabilities you need.
|
||||
* Updated our [`parse5`](https://github.com/inikulin/parse5/) dependency to v5, which changes the format of the node locations returned by `dom.nodeLocation()`.
|
||||
* Updated our [`whatwg-url`](https://github.com/jsdom/whatwg-url) dependency to v7, which changes the origin of `file:` URLs to be an opaque origin (and thus `file:` URLs are no longer same origin to each other).
|
||||
|
||||
Other changes:
|
||||
|
||||
* Added `countReset()`, `dir()` and `dirxml()` methods to `console`.
|
||||
* Added the `InputEvent` class.
|
||||
* Added `window.status`.
|
||||
* Added `htmlElement.draggable`.
|
||||
* Fixed `window.frameElement` to correctly return an actual `HTMLElement` instance, instead of a jsdom internal class.
|
||||
* Fixed cloning of `textarea` elements to preserve their values.
|
||||
* Fixed `select.selectedOptions` sometimes returning outdated results.
|
||||
* Fixed CSS selection APIs sometimes returning outdated results, especially for state pseudo-class selectors like `:checked`.
|
||||
* Fixed CSS selection APIs to throw an error for invalid selectors even when used on empty nodes.
|
||||
* Fixed `window.name` to default to the empty string, per spec, instead of `"nodejs"`.
|
||||
* Fixed the default User-Agent to say "unknown OS" instead of "undefined" when jsdom is used in web browsers.
|
||||
|
||||
## 11.12.0
|
||||
|
||||
* Added `window.localStorage`, `window.sessionStorage`, and `StorageEvent` support. These are currently only stored in-memory; file an issue if you need persistent (on-disk) storage capability so we can discuss adding that. This feature includes the new `storageQuota` option for controlling how much can be stored.
|
||||
* Added `element.closest()`. (caub)
|
||||
* Changed `"hashchange"` and `"popstate"` events to no longer bubble, per a specification update.
|
||||
* Changed `hashchange` and `popstate` events to no longer bubble, per a specification update.
|
||||
* Fixed the old API in Node.js v10 to not throw, when given input that is not a valid file path (such as a typical HTML string).
|
||||
* Upgraded `cssstyle` to v1.0.0, bringing along various fixes to our CSS parser and object model. (eddies)
|
||||
* Upgraded `nwsapi` to v2.0.7, bringing along various fixes to our selector engine.
|
||||
@@ -43,14 +340,14 @@
|
||||
* Added `FileReader`'s `readAsBinaryString()` method, as it has been added back to the specification.
|
||||
* Fixed event handlers to be own properties of each `Window`, instead of on `Window.prototype`. (Fetz)
|
||||
* Fixed an exception that would sometimes get raised when removing an `<img>` element's `src=""` attribute. (atsikov)
|
||||
* Fixed `"abort"` events on `AbortSignal`s to have their `isTrusted` set to true.
|
||||
* Fixed `abort` events on `AbortSignal`s to have their `isTrusted` set to true.
|
||||
* Fixed some argument conversions in `XMLHttpRequest`'s `open()` method.
|
||||
* Improved MIME type and data: URL parsing throughout jsdom, by using the new [`whatwg-mimetype`](https://www.npmjs.com/package/whatwg-mimetype) and [`data-urls`](https://www.npmjs.com/package/data-urls) packages.
|
||||
* Improved MIME type and `data:` URL parsing throughout jsdom, by using the new [`whatwg-mimetype`](https://www.npmjs.com/package/whatwg-mimetype) and [`data-urls`](https://www.npmjs.com/package/data-urls) packages.
|
||||
* Removed some unnecessary `.webidl` files that were included in the npm package.
|
||||
|
||||
## 11.6.2
|
||||
|
||||
* Fixed another regression (since v11.6.0) in `<style>` elements, where they would omit a series of parsing `"jsdomError"`s for any style sheet text containing spaces.
|
||||
* Fixed another regression (since v11.6.0) in `<style>` elements, where they would omit a series of parsing `jsdomError` events for any style sheet text containing spaces.
|
||||
* Generally improved the spec-conformance of when `<style>` and `<script>` elements are evaluated; for example, `<script>` elements inserted by `innerHTML` are no longer evaluated.
|
||||
|
||||
## 11.6.1
|
||||
@@ -58,7 +355,7 @@
|
||||
* Fixed one regression (since v11.6.0) in `<style>` elements, where their `sheet` property would sometimes be `null` when it should not be.
|
||||
* Fixed a case where a `<style>` element's `sheet` property would be left as a `CSSStyleSheet` despite it not being in the document.
|
||||
|
||||
Another regression remains where we are emitting spurious CSS-parsing `"jsdomError"` events; see [#2123](https://github.com/tmpvar/jsdom/issues/2123). We also discovered a large amount of preexisting brokenness around `<style>`, `<link>`, and `@import`; see [#2124](https://github.com/tmpvar/jsdom/issues/2124) for more details.
|
||||
Another regression remains where we are emitting spurious CSS-parsing `jsdomError` events; see [#2123](https://github.com/jsdom/jsdom/issues/2123). We also discovered a large amount of preexisting brokenness around `<style>`, `<link>`, and `@import`; see [#2124](https://github.com/jsdom/jsdom/issues/2124) for more details.
|
||||
|
||||
We'll try to fix these soon, especially the regression.
|
||||
|
||||
@@ -77,7 +374,7 @@ We'll try to fix these soon, especially the regression.
|
||||
* Fixed the firing of `popstate` and `hashchange` events during fragment navigation to make them trusted events.
|
||||
* Fixed `data:` URL parsing to not include the fragment portions.
|
||||
* Fixed all URL-accepting properties to properly perform [scalar value string conversion](https://infra.spec.whatwg.org/#javascript-string-convert) and URL resolution.
|
||||
* Fixed many other small edge-case conformance issues in the API surface of various web APIs; see [#2053](https://github.com/tmpvar/jsdom/pull/2053) and [#2081](https://github.com/tmpvar/jsdom/pull/2081) for more information.
|
||||
* Fixed many other small edge-case conformance issues in the API surface of various web APIs; see [#2053](https://github.com/jsdom/jsdom/pull/2053) and [#2081](https://github.com/jsdom/jsdom/pull/2081) for more information.
|
||||
* Fixed various APIs to use ASCII lowercasing, instead of Unicode lowercasing, for element and attribute names.
|
||||
* Fixed the encoding of a document created via `new Document()` to be UTF-8.
|
||||
* Fixed event handler properties behavior when given non-callable objects.
|
||||
@@ -94,10 +391,10 @@ We'll try to fix these soon, especially the regression.
|
||||
|
||||
## 11.4.0
|
||||
|
||||
For this release we'd like to welcome [@Zirro](https://github.com/tmpvar/jsdom/commits?author=Zirro) to the core team; his contributions over the course of this year have enhanced jsdom immensely.
|
||||
For this release we'd like to welcome [@Zirro](https://github.com/jsdom/jsdom/commits?author=Zirro) to the core team; his contributions over the course of this year have enhanced jsdom immensely.
|
||||
|
||||
* Added a rudimentary set of SVG element classes, namely `SVGElement`, `SVGGraphicsElement`, `SVGSVGElement`, `SVGTests`, `SVGAnimatedString`, `SVGNumber`, and `SVGStringList`. The main impact here is that SVG elements are now instances of `SVGElement`, instead of being simply `Element` (as they were in v11.3.0) or `HTMLUnknownElement` (as they were in v11.2.0 and previously). The only concrete subclass that is implemented is `SVGSVGElement`, for `<svg>` itself; other tags will not map to their correct classes, because those classes are not yet implemented.
|
||||
* Added the new `pretendToBeVisual` option, which controls the presence of the new `requestAnimationFrame()` and `cancelAnimationFrame()` methods, and the new values of `document.hidden`/`document.visibilityState`. [See the README](https://github.com/tmpvar/jsdom#pretending-to-be-a-visual-browser) for more information. (SimenB)
|
||||
* Added the new `pretendToBeVisual` option, which controls the presence of the new `requestAnimationFrame()` and `cancelAnimationFrame()` methods, and the new values of `document.hidden`/`document.visibilityState`. [See the README](https://github.com/jsdom/jsdom#pretending-to-be-a-visual-browser) for more information. (SimenB)
|
||||
* Added the `append()` and `prepend()` methods to `Document`, `DocumentFragment`, and `Element`. (caub)
|
||||
* Added the `before()`, `after()`, and `replaceWith()` methods to `DocumentType`, `Element`, and `CharacterData`. (caub)
|
||||
* Added `node.isConnected`.
|
||||
@@ -116,7 +413,7 @@ For this release we'd like to welcome [@Zirro](https://github.com/tmpvar/jsdom/c
|
||||
|
||||
## 11.3.0
|
||||
|
||||
For this release we'd like to formally welcome [@TimothyGu](https://github.com/tmpvar/jsdom/commits?author=TimothyGu) to the core team, as a prolific contributor. He will join the illustrious ranks of those who do so much work on jsdom that we no longer note their names in the changelog.
|
||||
For this release we'd like to formally welcome [@TimothyGu](https://github.com/jsdom/jsdom/commits?author=TimothyGu) to the core team, as a prolific contributor. He will join the illustrious ranks of those who do so much work on jsdom that we no longer note their names in the changelog.
|
||||
|
||||
* Added `table.tHead`, `table.tFoot`, and `table.caption` setters, and the `table.createTBody()` method.
|
||||
* Added `CompositionEvent` and `WheelEvent` classes.
|
||||
@@ -147,7 +444,7 @@ This release brings with it a much-awaited infrastructure change, as part of [we
|
||||
* Added suport for `FileList` indexed properties, i.e. `fileList[i]`.
|
||||
* Made `select.options` an instance of the newly-implemented `HTMLOptionsCollection`, instead of just a `HTMLCollection`.
|
||||
|
||||
This infrastructure will allow us to improve and implement many other similar behaviors; that work is being tracked in [#1129](https://github.com/tmpvar/jsdom/issues/1129).
|
||||
This infrastructure will allow us to improve and implement many other similar behaviors; that work is being tracked in [#1129](https://github.com/jsdom/jsdom/issues/1129).
|
||||
|
||||
In addition to these improvements to the object model, we have more work to share:
|
||||
|
||||
@@ -213,7 +510,7 @@ Other changes:
|
||||
* Changed `XMLHttpRequest` to pre-allocate a 1 MiB buffer, which it grows exponentially as needed, in order to avoid frequent buffer allocation and concatenation. (skygon)
|
||||
* Fixed a variety of properties that were meant to always return the same object, to actually do so. (Zirro)
|
||||
* Fixed inheritance of the `runScripts` and `resources` options into iframes.
|
||||
* Fixed an uncaught exception that occurred if you called `xhr.abort()` during a `"readystatechange"` event.
|
||||
* Fixed an uncaught exception that occurred if you called `xhr.abort()` during a `readystatechange` event.
|
||||
|
||||
## 10.0.0
|
||||
|
||||
@@ -227,7 +524,7 @@ Apart from the new API, the following changes were made, with breaking changes b
|
||||
* **Changed the `omitJsdomErrors` option to `omitJSDOMErrors`**, for consistency [with web platform APIs](https://w3ctag.github.io/design-principles/#casing-rules).
|
||||
* Added `document.dir`. (Zirro)
|
||||
* Updated the `<a>` and `<area>` APIs to the latest specification, and fixed a few bugs with them. (makana)
|
||||
* Fixed `<img>` elements to no longer fire `"load"` events unless their image data is actually loaded (which generally only occurs when the `canvas` package is installed).
|
||||
* Fixed `<img>` elements to no longer fire `load` events unless their image data is actually loaded (which generally only occurs when the `canvas` package is installed).
|
||||
* Fixed `XMLHttpRequest` preflights to forward approved preflight headers to the actual request. (mbroadst)
|
||||
* Fixed `htmlElement.dir` to properly restrict its values to `"ltr"`, `"rtl"`, or `"auto"`. (Zirro)
|
||||
* Fixed setting `innerHTML` to the empty string to no longer be a no-op. (Zirro)
|
||||
@@ -293,7 +590,7 @@ Apart from the new API, the following changes were made, with breaking changes b
|
||||
* Added the `blob.isClosed` property. (TimothyGu)
|
||||
* Fixed the `file.lastModified` property to be on `File` instead of on `Blob`. (TimothyGu)
|
||||
* Fixed the `file.lastModified` property to default to the time of the `File` object's creation, not the time that the property is accessed. (TimothyGu)
|
||||
* Fixed a minor edge-case regression where non-HTML elements with the name `"iframe"` became focusable in 9.7.0.
|
||||
* Fixed a minor edge-case regression where non-HTML elements with the name `"iframe"` became focusable in v9.7.0.
|
||||
|
||||
## 9.7.1
|
||||
|
||||
@@ -323,11 +620,11 @@ Apart from the new API, the following changes were made, with breaking changes b
|
||||
|
||||
## 9.4.5
|
||||
|
||||
* Fixed `"error"` events from failed resource loads going missing since 9.4.3. I really should have tested that release better.
|
||||
* Fixed `error` events from failed resource loads going missing since v9.4.3. I really should have tested that release better.
|
||||
|
||||
## 9.4.4
|
||||
|
||||
* Fixed a leftover `console.log` introduced in the error handling path in 9.4.3.
|
||||
* Fixed a leftover `console.log` introduced in the error handling path in v9.4.3.
|
||||
|
||||
## 9.4.3
|
||||
|
||||
@@ -400,7 +697,7 @@ Apart from the new API, the following changes were made, with breaking changes b
|
||||
* Fixed `formEl.action` to return a value resolved relative to the document URL, or to return the document URL if the corresponding attribute is missing or empty.
|
||||
* Sped up XPath execution. (vsemozhetbyt)
|
||||
* Fixed `window.close()` not correctly clearing event listeners on the document. (Ojek)
|
||||
* Fixed a regression introduced in 9.0.0 where invalid CSS would cause a crash while attempting to parse it. Instead, a `"jsdomError"` will now be emitted to the virtual console.
|
||||
* Fixed a regression introduced in v9.0.0 where invalid CSS would cause a crash while attempting to parse it. Instead, a `"jsdomError"` will now be emitted to the virtual console.
|
||||
|
||||
## 9.0.0
|
||||
|
||||
@@ -408,7 +705,7 @@ This major release removes jsdom's support for mutation events. Mutation events
|
||||
|
||||
However, recent performance investigations revealed that mutation events were the major bottleneck in most jsdom operations; tools like [ecmarkup](https://github.com/bterlson/ecmarkup) which make heavy use of jsdom had their running time halved by removing mutation events, which add serious overhead to every DOM mutation. As such, we are doing a major release with them removed, so that jsdom users can benefit from this massive performance gain.
|
||||
|
||||
Mutation observer support is [in progress](https://github.com/tmpvar/jsdom/issues/639); please use the GitHub reactions feature to vote on that issue if you are impacted by this removal and are hoping for mutation observer support to replace it.
|
||||
Mutation observer support is [in progress](https://github.com/jsdom/jsdom/issues/639); please use the GitHub reactions feature to vote on that issue if you are impacted by this removal and are hoping for mutation observer support to replace it.
|
||||
|
||||
Your normal change log follows:
|
||||
|
||||
@@ -438,7 +735,7 @@ Your normal change log follows:
|
||||
## 8.4.0
|
||||
|
||||
* Added an implementation of the `TreeWalker` class (and `document.createTreeWalker`). (garycourt)
|
||||
* Fixed a few minor bugs in URL parsing and the `URL` API, by upgrading to `whatwg-url` 2.0.1.
|
||||
* Fixed a few minor bugs in URL parsing and the `URL` API, by upgrading to `whatwg-url` v2.0.1.
|
||||
* Fixed a few issues with generated files in the published package, which seem to have impacted webpack users.
|
||||
|
||||
## 8.3.1
|
||||
@@ -452,7 +749,7 @@ Your normal change log follows:
|
||||
* `load` and `error` events will fire on the `<img>` element, according to how well image decoding goes.
|
||||
* You can draw images onto canvases, using the newly-enabled `canvasContext.drawImage` API.
|
||||
* Added `canvasContext.createPattern` and `canvasContext.toBlob`, when the `canvas` npm package is installed. (lehni)
|
||||
* Added a basic implementation of the [Page Visibility API](https://w3c.github.io/page-visibility/), in particular a `document.hidden` property that always returns `true`, and a `document.visibilityState` property that always returns `"prerender"`. This is a more standard alternative to our proprietary `navigator.noUI`, which will be removed whenever we release 9.0.0. (kapouer)
|
||||
* Added a basic implementation of the [Page Visibility API](https://w3c.github.io/page-visibility/), in particular a `document.hidden` property that always returns `true`, and a `document.visibilityState` property that always returns `"prerender"`. This is a more standard alternative to our proprietary `navigator.noUI`, which will be removed whenever we release v9.0.0. (kapouer)
|
||||
|
||||
## 8.2.0
|
||||
|
||||
@@ -539,7 +836,7 @@ Although normally jsdom does not mark a new major release for changes that simpl
|
||||
## 7.2.0
|
||||
|
||||
* Added support for text selection APIs on `<input>` and `<textarea>`! (sjelin and yaycmyk)
|
||||
* Replaced our default XML parser with [sax](https://www.npmjs.com/package/sax), thus fixing many (but not all) issues with XML and XHTML parsing. To get a flavor of the issues fixed, check out these now-closed bugs: [#393](https://github.com/tmpvar/jsdom/issues/393), [#651](https://github.com/tmpvar/jsdom/issues/651), [#415](https://github.com/tmpvar/jsdom/issues/415), [#1276](https://github.com/tmpvar/jsdom/issues/1276).
|
||||
* Replaced our default XML parser with [sax](https://www.npmjs.com/package/sax), thus fixing many (but not all) issues with XML and XHTML parsing. To get a flavor of the issues fixed, check out these now-closed bugs: [#393](https://github.com/jsdom/jsdom/issues/393), [#651](https://github.com/jsdom/jsdom/issues/651), [#415](https://github.com/jsdom/jsdom/issues/415), [#1276](https://github.com/jsdom/jsdom/issues/1276).
|
||||
* Fixed the `<canvas>` tag to reset its contents when its width or height changed, including the change from the default 300 × 150 canvas. (Applies only when using the `canvas` npm package.)
|
||||
* Fixed an issue where `HTMLCollection`s would get confused when they contained elements with numeric `id`s or `name`s.
|
||||
* Fixed an issue with doctype parsing confusing the system ID and public ID.
|
||||
@@ -618,7 +915,7 @@ This major release has as its headlining feature a completely re-written `XMLHtt
|
||||
* Added a fully spec-compliant implementation of `window.atob` and `window.btoa`. (jeffcarp)
|
||||
* Fixed many issues with our `<canvas>` implementation:
|
||||
- With the `canvas` npm package installed, `<canvas>` elements are now properly `instanceof HTMLCanvasElement` and `instanceof HTMLElement`.
|
||||
- `<canvas>` elements now present the same uniform spec-compliant API both with and without the `canvas` npm package installed. If the package is not installed, some of the methods will cause not-implemented `"jsdomError"` events to be emitted on the virtual console.
|
||||
- `<canvas>` elements now present the same uniform spec-compliant API both with and without the `canvas` npm package installed. If the package is not installed, some of the methods will cause not-implemented `jsdomError` events to be emitted on the virtual console.
|
||||
- The `width` and `height` properties now correctly reflect the `width` and `height` attributes, and have the appropriate default values of `300` and `150`.
|
||||
- With the `canvas` npm package installed, `<canvas>` elements now generally play better with other parts of jsdom, e.g., `document.getElementById` actually works with them.
|
||||
* Introduced and upated many of our element classes, so that at least every tag name/element class pair is now correct, even if some of the classes are stubs. In particular:
|
||||
@@ -632,7 +929,7 @@ This major release has as its headlining feature a completely re-written `XMLHtt
|
||||
- Added `Node.prototype.baseURI` property to get the node's owner document's base URL.
|
||||
- `HTMLBaseElement`'s `href` getter now contains appropriate fallbacks and always returns an absolute URL, per spec.
|
||||
- If there are no `base` elements in an `"about:blank"` iframe document, the base URL correctly falls back to the parent window's base URL.
|
||||
* When you provide a `url: ...` option to `jsdom.jsom()` or `jsdom.env()`, the given string is now attempted to be resolved as a URL before it is installed as `document.URL`.
|
||||
* When you provide a `url: ...` option to `jsdom.jsdom()` or `jsdom.env()`, the given string is now attempted to be resolved as a URL before it is installed as `document.URL`.
|
||||
- So for example, providing `url: "http://example.com"` will mean `document.URL` returns `"http://example.com/"`, with a trailing slash.
|
||||
- In a future major release, we will start throwing if strings that cannot be parsed as valid absolute URL are provided for this option.
|
||||
|
||||
@@ -642,7 +939,7 @@ This major release has as its headlining feature a completely re-written `XMLHtt
|
||||
* Made `virtualConsole.sendTo(console)` forward `"jsdomError"`s to `console` by calling `console.error`. This can be turned off by doing `virtualConsole.sendTo(console, { omitJsdomErrors: true })`.
|
||||
* Fixed errors when trying to parse invalid doctype declarations, like `<!DOCTYPE>`.
|
||||
* Fixed spurious `"jsdomError"`s that were emitted after calling `window.close()`.
|
||||
* Fixed the `"DOMSubtreeModified"` event to fire in more cases. Note that our mutation events implementation remains incomplete, and will eventually be removed (in a major release) once we implement mutation observers. (selam)
|
||||
* Fixed the `DOMSubtreeModified` event to fire in more cases. Note that our mutation events implementation remains incomplete, and will eventually be removed (in a major release) once we implement mutation observers. (selam)
|
||||
|
||||
## 6.1.0
|
||||
|
||||
@@ -657,7 +954,7 @@ This major release has as its headlining feature a completely re-written `XMLHtt
|
||||
|
||||
This major release is focused on massive improvements in speed, URL parsing, and error handling. The potential breaking changes are highlighted in bold below; the largest ones are around the `jsdom.env` error-handling paradigm.
|
||||
|
||||
This release also welcomes [long-time contributer](https://github.com/tmpvar/jsdom/commits/master?author=Joris-van-der-Wel) [@Joris-van-der-Wel](https://github.com/Joris-van-der-Wel/) to the core team. You may recognize him from earlier changelogs. We're very happy to have his help in making jsdom awesome!
|
||||
This release also welcomes [long-time contributer](https://github.com/jsdom/jsdom/commits/master?author=Joris-van-der-Wel) [@Joris-van-der-Wel](https://github.com/Joris-van-der-Wel/) to the core team. You may recognize him from earlier changelogs. We're very happy to have his help in making jsdom awesome!
|
||||
|
||||
* **io.js 2.0 onward is now required**, as we have begun using ES2015 features only present there.
|
||||
* Improved performance dramatically, by ~10000x in some cases, due to the following changes:
|
||||
@@ -666,7 +963,7 @@ This release also welcomes [long-time contributer](https://github.com/tmpvar/jsd
|
||||
- Sped up `node.compareDocumentPosition` and anything that used it (like `node.contains`) by doing more intelligent tree traversal instead of directly implementing the specced algorithm.
|
||||
* Overhauled how error handling works in jsdom:
|
||||
- `window.onerror` (or `window.addEventListener("error", ...)`) now work, and will catch all script errors, similar to in browsers. This also introduces the `ErrorEvent` class, incidentally.
|
||||
- The virtual console is now the destination for several types of errors from jsdom, using [the new event `"jsdomError"`](https://github.com/tmpvar/jsdom#virtual-console-jsdomerror-error-reporting). This includes: errors loading external resources; script execution errors unhandled by `window.onerror`; and not-implemented warnings resulting from calling methods like `window.alert` which jsdom explicitly does not support.
|
||||
- The virtual console is now the destination for several types of errors from jsdom, using [the new event `"jsdomError"`](https://github.com/jsdom/jsdom#virtual-console-jsdomerror-error-reporting). This includes: errors loading external resources; script execution errors unhandled by `window.onerror`; and not-implemented warnings resulting from calling methods like `window.alert` which jsdom explicitly does not support.
|
||||
- Since script errors are now handled by `window.onerror` and the virtual console, they are no longer included in the initialization process. This results in two changes to `jsdom.env` and the initialization lifecycle:
|
||||
+ **The `load(errors, window)` callback was changed to `onload(window)`**, to reflect that it is now just sugar for setting a `window.onload` handler.
|
||||
+ **The `done(errors, window)` callback (i.e., the default callback for `jsdom.env`) has become `done(error, window)`**, and like every other io.js callback now simply gives you a single error object, instead of an array of them.
|
||||
@@ -679,27 +976,27 @@ This release also welcomes [long-time contributer](https://github.com/tmpvar/jsd
|
||||
* Added the `XMLHttpRequest.prototype.response` getter.
|
||||
* Fixed `StyleSheetList.prototype.item` to actually work. (chad3814)
|
||||
* Fixed the browser `vm` shim to properly add the built-in global properties (`Object`, `Array`, etc.) to the sandbox. If you were running jsdom inside a web worker and most of your scripts were broken, this should fix that.
|
||||
* Fixed the `"hashchange"` event to correctly fire `HashChangeEvent` instances, with correct properties `newURL` and `oldURL` (instead of the incorrect `newUrl` and `oldUrl` used previously).
|
||||
* Fixed the `hashchange` event to correctly fire `HashChangeEvent` instances, with correct properties `newURL` and `oldURL` (instead of the incorrect `newUrl` and `oldUrl` used previously).
|
||||
* Removed usage of the setimmediate library, as it required `eval` and thus did not work in CSP scenarios.
|
||||
|
||||
Finally, if you're a loyal jsdom fan whose made it this far into the changelog, I'd urge you to come join us in [#1139](https://github.com/tmpvar/jsdom/issues/1139), where we are brainstorming a modernized jsdom API that could get rid of many of the warts in the current one.
|
||||
Finally, if you're a loyal jsdom fan whose made it this far into the changelog, I'd urge you to come join us in [#1139](https://github.com/jsdom/jsdom/issues/1139), where we are brainstorming a modernized jsdom API that could get rid of many of the warts in the current one.
|
||||
|
||||
## 5.6.1
|
||||
|
||||
* Fixed an accidentally-created global `attribute` variable if you ever called `createAttributeNS`.
|
||||
* Dependency upgrades fixed a couple of bugs, although you would have gotten these anyway with a clean jsdom 5.6.0 install:
|
||||
- Parsing of CSS properties that use `url("quoted string")` now works correctly, as of `cssstyle` 0.2.29.
|
||||
- Selectors for the empty string, like `div[title=""]`, now work correctly, as of `nwmatcher` 1.3.6.
|
||||
* Dependency upgrades fixed a couple of bugs, although you would have gotten these anyway with a clean jsdom v5.6.0 install:
|
||||
- Parsing of CSS properties that use `url("quoted string")` now works correctly, as of `cssstyle` v0.2.29.
|
||||
- Selectors for the empty string, like `div[title=""]`, now work correctly, as of `nwmatcher` v1.3.6.
|
||||
|
||||
## 5.6.0
|
||||
|
||||
* `virtualConsole.sendTo` now returns `this`, allowing for [a nice shorthand](https://github.com/tmpvar/jsdom/tree/60ccb9b318d0bae8fe37e19af5af444b9c98ddac#forward-a-windows-console-output-to-the-iojs-console). (jeffcarp)
|
||||
* `virtualConsole.sendTo` now returns `this`, allowing for [a nice shorthand](https://github.com/jsdom/jsdom/tree/60ccb9b318d0bae8fe37e19af5af444b9c98ddac#forward-a-windows-console-output-to-the-iojs-console). (jeffcarp)
|
||||
|
||||
## 5.5.0
|
||||
|
||||
* Added `postMessage` support, for communicating between parent windows, iframes, and combinations thereof. It's missing a few semantics, especially around origins, as well as MessageEvent source. Objects are not yet structured cloned, but instead passed by reference. But it's working, and awesome! (jeffcarp)
|
||||
* Rewrote cloning code (underlying `cloneNode` and `importNode`), fixing a number of issues:
|
||||
- Elements with weird tag names, of the type that only the parser can normally create, can now be cloned ([#1142](https://github.com/tmpvar/jsdom/issues/1142))
|
||||
- Elements with weird tag names, of the type that only the parser can normally create, can now be cloned ([#1142](https://github.com/jsdom/jsdom/issues/1142))
|
||||
- Doctypes can now be cloned, per the latest spec.
|
||||
- Attrs cannot be cloned, per the latest spec (although they still have a `cloneNode` method for now due to legacy).
|
||||
- Document clones now correctly copy over the URL and content-type.
|
||||
@@ -708,7 +1005,7 @@ Finally, if you're a loyal jsdom fan whose made it this far into the changelog,
|
||||
* Fixed clicking on submit `<button>`s to submit their containing form; previously only `<input type="submit">` worked. (rxgx)
|
||||
* Fixed `document.open()` to return `this`, per spec. (ryanseddon)
|
||||
|
||||
Additionally, Joris-van-der-Wel added [a benchmarking framework](https://github.com/tmpvar/jsdom/blob/master/Contributing.md#running-the-benchmarks), and a number of benchmarks, which should help us avoid performance regressions going forward, and also make targeted performance fixes. We're already investigating [some real-world issues](https://github.com/tmpvar/jsdom/issues/1156) using this framework. Very exciting!
|
||||
Additionally, Joris-van-der-Wel added [a benchmarking framework](https://github.com/jsdom/jsdom/blob/master/Contributing.md#running-the-benchmarks), and a number of benchmarks, which should help us avoid performance regressions going forward, and also make targeted performance fixes. We're already investigating [some real-world issues](https://github.com/jsdom/jsdom/issues/1156) using this framework. Very exciting!
|
||||
|
||||
## 5.4.3
|
||||
|
||||
@@ -720,14 +1017,14 @@ Additionally, Joris-van-der-Wel added [a benchmarking framework](https://github.
|
||||
|
||||
## 5.4.1
|
||||
|
||||
* Fixed to work with browserify again (regression introduced in 5.4.0).
|
||||
* Fixed to work with browserify again (regression introduced in v5.4.0).
|
||||
|
||||
## 5.4.0
|
||||
|
||||
This is a pretty exciting release! It includes a couple features I never really anticipated jsdom being awesome enough to have, but our wonderful contributors powered through and made them happen anyway:
|
||||
|
||||
* Added support for the default HTML stylesheet when using `window.getComputedStyle`! (akhaku)
|
||||
- Notably, this makes jQuery's `show()` and `hide()` methods now work correctly; see [#994](https://github.com/tmpvar/jsdom/issues/994).
|
||||
- Notably, this makes jQuery's `show()` and `hide()` methods now work correctly; see [#994](https://github.com/jsdom/jsdom/issues/994).
|
||||
* Added support for named properties on `window`: any elements with an `id` attribute, or certain elements with a `name` attribute, will cause properties to show up on the `window`, and thus as global variables within the jsdom. (Joris-van-der-Wel)
|
||||
- Although this is fairly unfortunate browser behavior, it's standardized and supported everywhere, so the fact that jsdom now supports this too means we can run a lot of scripts that would previously fail.
|
||||
- Previously, we only supported this for `<iframe>`s, and our implementation was quite buggy: e.g., `<iframe name="addEventListener">` would override `window.addEventListener`.
|
||||
@@ -739,7 +1036,7 @@ We also have a bunch more fixes and additions:
|
||||
* Updated `StyleSheetList` to inherit from `Array`, as per the latest CSSOM spec.
|
||||
* Overhauled the handling of attributes throughout the DOM, to follow the spec more exactly.
|
||||
- Our `NamedNodeMap` implementation is up to date, as are the various `Element` methods; other places in the code that deal with attributes now all go through a spec-compliant set of helpers.
|
||||
- Some weirdnesses around the `style` attribute were fixed along the way; see e.g. [#1109](https://github.com/tmpvar/jsdom/issues/1109).
|
||||
- Some weirdnesses around the `style` attribute were fixed along the way; see e.g. [#1109](https://github.com/jsdom/jsdom/issues/1109).
|
||||
- However, `Attr` objects themselves are not yet spec-compliant (e.g., they still inherit from `Node`). That's coming soon.
|
||||
* Fixed an unfortunate bug where `getElementById` would fail to work correctly on `<img>` elements whose `id` attributes were modified. (Joris-van-der-Wel)
|
||||
* Fixed the `virtualConsole` option to work with `jsdom.env`, not just `jsdom.jsdom`. (jeffcarp)
|
||||
@@ -747,7 +1044,7 @@ We also have a bunch more fixes and additions:
|
||||
|
||||
## 5.3.0
|
||||
|
||||
* Added a `virtualConsole` option to the document creation methods, along with the `jsdom.createVirtualConsole` factory. (See [examples in the readme](https://github.com/tmpvar/jsdom/blob/dbf88666d1152576237ed1c741263f5516bb4005/README.md#capturing-console-output).) With this option you can install a virtual console before the document is even created, thus allowing you to catch any virtual console events that occur during initialization. (jeffcarp)
|
||||
* Added a `virtualConsole` option to the document creation methods, along with the `jsdom.createVirtualConsole` factory. (See [examples in the readme](https://github.com/jsdom/jsdom/blob/dbf88666d1152576237ed1c741263f5516bb4005/README.md#capturing-console-output).) With this option you can install a virtual console before the document is even created, thus allowing you to catch any virtual console events that occur during initialization. (jeffcarp)
|
||||
|
||||
## 5.2.0
|
||||
|
||||
@@ -791,7 +1088,7 @@ In addition to these changes to the public API, the following new cookie-related
|
||||
* Implemented automatic cookie-jar sharing with descendant `<iframe>`s. (So, if the iframe is same-domain, it can automatically access the appropriate cookies.)
|
||||
* Let `options.document.cookie` accept arrays, instead of just strings, for if you want to set multiple cookies at once.
|
||||
|
||||
Finally, it's worth noting that we now delegate our cookie handling in general to the [tough-cookie](https://www.npmjs.com/package/tough-cookie) package, which should hopefully mean that it now captures many of the behaviors that were previously missing (for example [#1027](https://github.com/tmpvar/jsdom/issues/1027)). @inikulin is working on [a large pull request to fix tough-cookie to be more spec compliant](https://github.com/goinstant/tough-cookie/pull/30), which should automatically be picked up by jsdom installs once it is merged.
|
||||
Finally, it's worth noting that we now delegate our cookie handling in general to the [tough-cookie](https://www.npmjs.com/package/tough-cookie) package, which should hopefully mean that it now captures many of the behaviors that were previously missing (for example [#1027](https://github.com/jsdom/jsdom/issues/1027)). @inikulin is working on [a large pull request to fix tough-cookie to be more spec compliant](https://github.com/goinstant/tough-cookie/pull/30), which should automatically be picked up by jsdom installs once it is merged.
|
||||
|
||||
## 4.5.1
|
||||
|
||||
@@ -859,7 +1156,7 @@ _Note:_ this probably should have been a minor version number increment (i.e. 4.
|
||||
|
||||
This release relies on the newly-overhauled `vm` module of io.js to eliminate the Contextify native module dependency. jsdom should now be much easier to use and install, without requiring a C++ compiler toolchain!
|
||||
|
||||
Note that as of this release, jsdom no longer works with Node.js™, and instead requires io.js. You are still welcome to install a release in [the 3.x series](https://github.com/tmpvar/jsdom/tree/3.x) if you are stuck on legacy technology like Node.js™.
|
||||
Note that as of this release, jsdom no longer works with Node.js™, and instead requires io.js. You are still welcome to install a release in [the 3.x series](https://github.com/jsdom/jsdom/tree/3.x) if you are stuck on legacy technology like Node.js™.
|
||||
|
||||
In the process of rewriting parts of jsdom to use `vm`, a number of related fixes were made regarding the `Window` object:
|
||||
|
||||
@@ -878,11 +1175,11 @@ In the process of rewriting parts of jsdom to use `vm`, a number of related fixe
|
||||
|
||||
* Updated `Node.prototype.isEqualNode` to the algorithm of the DOM Standard, fixing a bug where it would throw an error along the way.
|
||||
* Removed `Node.prototype.isSameNode`, which is not present in the DOM Standard (and was just a verbose `===` check anyway).
|
||||
* Fixed a couple small issues while browserifying, mainly around `jsdom.env`. However, while doing so discovered that `<script>`s in general don't work too well in a browserified jsdom; see [#1023](https://github.com/tmpvar/jsdom/issues/1023).
|
||||
* Fixed a couple small issues while browserifying, mainly around `jsdom.env`. However, while doing so discovered that `<script>`s in general don't work too well in a browserified jsdom; see [#1023](https://github.com/jsdom/jsdom/issues/1023).
|
||||
|
||||
## 3.1.0
|
||||
|
||||
* Added support for [custom external resource loading](https://github.com/tmpvar/jsdom#custom-external-resource-loader). (tobie)
|
||||
* Added support for [custom external resource loading](https://github.com/jsdom/jsdom#custom-external-resource-loader). (tobie)
|
||||
|
||||
## 3.0.3
|
||||
|
||||
@@ -905,7 +1202,7 @@ This release updates large swathes of the DOM APIs to conform to the standard, m
|
||||
3.0.x will be the last release of jsdom to support Node.js. All future releases (starting with 4.0.0) will require [io.js](https://iojs.org/), whose [new `vm` module](https://github.com/iojs/io.js/blob/v1.x/CHANGELOG.md#vm) will allow us to remove our contextify native-module dependency. (Given that I submitted the relevant patch to joyent/node [1.5 years ago](https://github.com/joyent/node/commit/7afdba6e0bc3b69c2bf5fdbd59f938ac8f7a64c5), I'm very excited that we can finally use it!)
|
||||
|
||||
* By default documents now use `about:blank` as their URL, instead of trying to infer some type of file URL from the call site (in Node.js) or using `location.href` (in browsers).
|
||||
* Introduced a new "virtual console" abstraction for capturing console output from inside the page. [See the readme for more information.](https://github.com/tmpvar/jsdom#capturing-console-output) Note that `console.error` will no longer contribute to the (non-standard, and likely dying in the future) `window.errors` array. (jeffcarp)
|
||||
* Introduced a new "virtual console" abstraction for capturing console output from inside the page. [See the readme for more information.](https://github.com/jsdom/jsdom#capturing-console-output) Note that `console.error` will no longer contribute to the (non-standard, and likely dying in the future) `window.errors` array. (jeffcarp)
|
||||
* Added the named `new Image(width, height)` constructor. (vinothkr)
|
||||
* Fixed an exception when using `querySelector` with selectors like `div:last-child > span[title]`.
|
||||
* Removed all traces of entities, entity types, notations, default attributes, and CDATA sections.
|
||||
@@ -923,7 +1220,7 @@ This release updates large swathes of the DOM APIs to conform to the standard, m
|
||||
|
||||
## 2.0.0
|
||||
|
||||
This release is largely a refactoring release to remove the defunct concept of "levels" from jsdom, in favor of the [living standard model](https://wiki.whatwg.org/wiki/FAQ#What_does_.22Living_Standard.22_mean.3F) that browsers follow. Although the code is still organized that way, that's now [noted as a historical artifact](https://github.com/tmpvar/jsdom/blob/2ff5747488ad4b518fcef97a026c82eab42a0a14/lib/README.md). The public API changes while doing so were fairly minimal, but this sets the stage for a cleaner jsdom code structure going forward.
|
||||
This release is largely a refactoring release to remove the defunct concept of "levels" from jsdom, in favor of the [living standard model](https://wiki.whatwg.org/wiki/FAQ#What_does_.22Living_Standard.22_mean.3F) that browsers follow. Although the code is still organized that way, that's now [noted as a historical artifact](https://github.com/jsdom/jsdom/blob/2ff5747488ad4b518fcef97a026c82eab42a0a14/lib/README.md). The public API changes while doing so were fairly minimal, but this sets the stage for a cleaner jsdom code structure going forward.
|
||||
|
||||
* Removed: `jsdom.level`, and the `level` option from `jsdom.jsdom`.
|
||||
* Change: the nonstandard `Element.prototype.matchesSelector` method was replaced with the standard `Element.prototype.matches`. (KenPowers)
|
||||
@@ -931,7 +1228,7 @@ This release is largely a refactoring release to remove the defunct concept of "
|
||||
|
||||
## 1.5.0
|
||||
|
||||
* Add: missing `window.console` methods, viz. `assert`, `clear`, `count`, `debug`, `group`, `groupCollapse`, `groupEnd`, `table`, `time`, `timeEnd`, and `trace`. All except `assert` do nothing for now, but see [#979](https://github.com/tmpvar/jsdom/issues/979) for future plans. (jeffcarp)
|
||||
* Add: missing `window.console` methods, viz. `assert`, `clear`, `count`, `debug`, `group`, `groupCollapse`, `groupEnd`, `table`, `time`, `timeEnd`, and `trace`. All except `assert` do nothing for now, but see [#979](https://github.com/jsdom/jsdom/issues/979) for future plans. (jeffcarp)
|
||||
* Tweak: make `childNodes`, and the many places in jsdom that use it, much faster. (Joris-van-der-Wel)
|
||||
|
||||
## 1.4.1
|
||||
@@ -996,7 +1293,7 @@ This release is largely a refactoring release to remove the defunct concept of "
|
||||
|
||||
* Fix: temporarily pin `cssstyle` dependency to at most 0.2.18 until [chad3814/CSSStyleDeclaration#20](https://github.com/chad3814/CSSStyleDeclaration/issues/20) is fixed.
|
||||
* Fix: browserifying jsdom should work better now that the required packages are included as `dependencies` instead of `devDependencies`. (Sebmaster)
|
||||
* Fix: using `jsom.env` in a browser environment now correctly defaults `options.url` to `location.href` instead of trying to infer a reasonable `fil://` URL using techniques that fail in the browser. (rattrayalex)
|
||||
* Fix: using `jsdom.env` in a browser environment now correctly defaults `options.url` to `location.href` instead of trying to infer a reasonable `fil://` URL using techniques that fail in the browser. (rattrayalex)
|
||||
|
||||
## 1.0.1
|
||||
|
||||
@@ -1004,7 +1301,7 @@ This release is largely a refactoring release to remove the defunct concept of "
|
||||
|
||||
## 1.0.0
|
||||
|
||||
For a consolidated list of changes from 0.11.1 to 1.0.0, see [this wiki page](https://github.com/tmpvar/jsdom/wiki/Changes-from-0.11.1-to-1.0.0).
|
||||
For a consolidated list of changes from 0.11.1 to 1.0.0, see [this wiki page](https://github.com/jsdom/jsdom/wiki/Changes-from-0.11.1-to-1.0.0).
|
||||
|
||||
* Remove: nonstandard `EventTarget.getListeners`; `EventTarget.forwardIterator`; `EventTarget.backwardIterator`; `EventTarget.singleIterator`.
|
||||
* Remove: nonstandard `document.innerHTML`. (jorendorff)
|
||||
@@ -1040,16 +1337,16 @@ For a consolidated list of changes from 0.11.1 to 1.0.0, see [this wiki page](ht
|
||||
|
||||
## 1.0.0-pre.1
|
||||
|
||||
This is a prerelease of jsdom's first major version. It incorporates several great additions, as well as a general cleanup of the API surface, which make it more backward-incompatible than usual. Starting with the 1.0.0 release, we will be following semantic versioning, so that you can depend on stability within major version ranges. But we still have [a few more issues](https://github.com/tmpvar/jsdom/issues?q=is%3Aopen+is%3Aissue+milestone%3A1.0) before we can get there, so I don't want to do 1.0.0 quite yet.
|
||||
This is a prerelease of jsdom's first major version. It incorporates several great additions, as well as a general cleanup of the API surface, which make it more backward-incompatible than usual. Starting with the 1.0.0 release, we will be following semantic versioning, so that you can depend on stability within major version ranges. But we still have [a few more issues](https://github.com/jsdom/jsdom/issues?q=is%3Aopen+is%3Aissue+milestone%3A1.0) before we can get there, so I don't want to do 1.0.0 quite yet.
|
||||
|
||||
This release owes a special thanks to [@Sebmaster](https://github.com/Sebmaster), for his amazing work taking on some of the hardest problems in jsdom and solving them with gusto.
|
||||
|
||||
### Major changes
|
||||
|
||||
* jsdom now can be browserified into a bundle that works in web workers! This is highly experimental, but also highly exciting! (lawnsea)
|
||||
* An overhaul of the [initialization lifecycle](https://github.com/tmpvar/jsdom#initialization-lifecycle), to bring more control and address common use cases. (Sebmaster)
|
||||
* An overhaul of the [initialization lifecycle](https://github.com/jsdom/jsdom#initialization-lifecycle), to bring more control and address common use cases. (Sebmaster)
|
||||
* The excellent [parse5](https://npmjs.org/package/parse5) HTML parser is now the default parser, fixing many parsing bugs and giving us full, official-test-suite-passing HTML parsing support. This especially impacts documents that didn't include optional tags like `<html>`, `<head>`, or `<body>` in their source. We also use parse5 for serialization, fixing many bugs there. (Sebmaster)
|
||||
* As part of the new parser story, we are not supporting XML for now. It might work if you switch to a different parser (e.g. htmlparser2), but in the end, HTML and XML are very different, and we are not attempting to be an XML DOM. That said, we eventually want to support XML to the same extent browsers do (i.e., support XHTML and SVG, with an appropriate MIME type switch); this is being planned in [#820](https://github.com/tmpvar/jsdom/issues/820).
|
||||
* As part of the new parser story, we are not supporting XML for now. It might work if you switch to a different parser (e.g. htmlparser2), but in the end, HTML and XML are very different, and we are not attempting to be an XML DOM. That said, we eventually want to support XML to the same extent browsers do (i.e., support XHTML and SVG, with an appropriate MIME type switch); this is being planned in [#820](https://github.com/jsdom/jsdom/issues/820).
|
||||
|
||||
### Removed jsdom APIs
|
||||
|
||||
@@ -1214,7 +1511,7 @@ This release owes a special thanks to [@Sebmaster](https://github.com/Sebmaster)
|
||||
## 0.6.4
|
||||
|
||||
* Fix: CSS selectors which contain commas inside quotes are no longer misinterpreted. (chad3814)
|
||||
* Add: `<img>` elements now fire `"load"` events when their `src` attributes are changed. (kapouer)
|
||||
* Add: `<img>` elements now fire `load` events when their `src` attributes are changed. (kapouer)
|
||||
|
||||
## 0.6.3
|
||||
|
||||
|
||||
165
node_modules/jsdom/README.md
generated
vendored
165
node_modules/jsdom/README.md
generated
vendored
@@ -5,9 +5,7 @@
|
||||
|
||||
jsdom is a pure-JavaScript implementation of many web standards, notably the WHATWG [DOM](https://dom.spec.whatwg.org/) and [HTML](https://html.spec.whatwg.org/multipage/) Standards, for use with Node.js. In general, the goal of the project is to emulate enough of a subset of a web browser to be useful for testing and scraping real-world web applications.
|
||||
|
||||
The latest versions of jsdom require Node.js v6 or newer. (Versions of jsdom below v10 still work with Node.js v4, but are unsupported.)
|
||||
|
||||
As of v10, jsdom has a new API (documented below). The old API is still supported for now; [see its documentation](./lib/old-api.md) for details.
|
||||
The latest versions of jsdom require Node.js v10 or newer. (Versions of jsdom below v16 still work with previous Node.js versions, but are unsupported.)
|
||||
|
||||
## Basic usage
|
||||
|
||||
@@ -25,7 +23,7 @@ console.log(dom.window.document.querySelector("p").textContent); // "Hello world
|
||||
|
||||
(Note that jsdom will parse the HTML you pass it just like a browser does, including implied `<html>`, `<head>`, and `<body>` tags.)
|
||||
|
||||
The resulting object is an instance of the `JSDOM` class, which contains a number of useful properties and methods besides `window`. In general it can be used to act on the jsdom from the "outside," doing things that are not possible with the normal DOM APIs. For simple cases, where you don't need any of this functionality, we recommend a coding pattern like
|
||||
The resulting object is an instance of the `JSDOM` class, which contains a number of useful properties and methods besides `window`. In general, it can be used to act on the jsdom from the "outside," doing things that are not possible with the normal DOM APIs. For simple cases, where you don't need any of this functionality, we recommend a coding pattern like
|
||||
|
||||
```js
|
||||
const { window } = new JSDOM(`...`);
|
||||
@@ -46,7 +44,6 @@ const dom = new JSDOM(``, {
|
||||
url: "https://example.org/",
|
||||
referrer: "https://example.com/",
|
||||
contentType: "text/html",
|
||||
userAgent: "Mellblomenator/9000",
|
||||
includeNodeLocations: true,
|
||||
storageQuota: 10000000
|
||||
});
|
||||
@@ -54,8 +51,7 @@ const dom = new JSDOM(``, {
|
||||
|
||||
- `url` sets the value returned by `window.location`, `document.URL`, and `document.documentURI`, and affects things like resolution of relative URLs within the document and the same-origin restrictions and referrer used while fetching subresources. It defaults to `"about:blank"`.
|
||||
- `referrer` just affects the value read from `document.referrer`. It defaults to no referrer (which reflects as the empty string).
|
||||
- `contentType` affects the value read from `document.contentType`, and how the document is parsed: as HTML or as XML. Values that are not `"text/html"` or an [XML mime type](https://html.spec.whatwg.org/multipage/infrastructure.html#xml-mime-type) will throw. It defaults to `"text/html"`.
|
||||
- `userAgent` affects the value read from `navigator.userAgent`, as well as the `User-Agent` header sent while fetching subresources. It defaults to <code>\`Mozilla/5.0 (${process.platform}) AppleWebKit/537.36 (KHTML, like Gecko) jsdom/${jsdomVersion}\`</code>.
|
||||
- `contentType` affects the value read from `document.contentType`, as well as how the document is parsed: as HTML or as XML. Values that are not a [HTML mime type](https://mimesniff.spec.whatwg.org/#html-mime-type) or an [XML mime type](https://mimesniff.spec.whatwg.org/#xml-mime-type) will throw. It defaults to `"text/html"`. If a `charset` parameter is present, it can affect [binary data processing](#encoding-sniffing).
|
||||
- `includeNodeLocations` preserves the location info produced by the HTML parser, allowing you to retrieve it with the `nodeLocation()` method (described below). It also ensures that line numbers reported in exception stack traces for code running inside `<script>` elements are correct. It defaults to `false` to give the best performance, and cannot be used with an XML content type since our XML parser does not support location info.
|
||||
- `storageQuota` is the maximum size in code units for the separate storage areas used by `localStorage` and `sessionStorage`. Attempts to store data larger than this limit will cause a `DOMException` to be thrown. By default, it is set to 5,000,000 code units per origin, as inspired by the HTML specification.
|
||||
|
||||
@@ -89,14 +85,14 @@ dom.window.document.body.children.length === 2;
|
||||
|
||||
Again we emphasize to only use this when feeding jsdom code you know is safe. If you use it on arbitrary user-supplied code, or code from the Internet, you are effectively running untrusted Node.js code, and your machine could be compromised.
|
||||
|
||||
If you want to execute _external_ scripts, included via `<script src="">`, you'll also need to ensure that they load them. To do this, add the option `resources: "usable"` [as described below](#loading-subresources).
|
||||
If you want to execute _external_ scripts, included via `<script src="">`, you'll also need to ensure that they load them. To do this, add the option `resources: "usable"` [as described below](#loading-subresources). (You'll likely also want to set the `url` option, for the reasons discussed there.)
|
||||
|
||||
Note that event handler attributes, like `<div onclick="">`, will also not function unless `runScripts` is set to `"dangerously"`. (However, event handler _properties_, like `div.onclick = ...`, will function regardless of `runScripts`.)
|
||||
Event handler attributes, like `<div onclick="">`, are also governed by this setting; they will not function unless `runScripts` is set to `"dangerously"`. (However, event handler _properties_, like `div.onclick = ...`, will function regardless of `runScripts`.)
|
||||
|
||||
If you are simply trying to execute script "from the outside", instead of letting `<script>` elements (and inline event handlers) run "from the inside", you can use the `runScripts: "outside-only"` option, which enables `window.eval`:
|
||||
If you are simply trying to execute script "from the outside", instead of letting `<script>` elements and event handlers attributes run "from the inside", you can use the `runScripts: "outside-only"` option, which enables fresh copies of all the JavaScript spec-provided globals to be installed on `window`. This includes things like `window.Array`, `window.Promise`, etc. It also, notably, includes `window.eval`, which allows running scripts, but with the jsdom `window` as the global:
|
||||
|
||||
```js
|
||||
const window = (new JSDOM(``, { runScripts: "outside-only" })).window;
|
||||
const { window } = new JSDOM(``, { runScripts: "outside-only" });
|
||||
|
||||
window.eval(`document.body.innerHTML = "<p>Hello, world!</p>";`);
|
||||
window.document.body.children.length === 1;
|
||||
@@ -104,9 +100,11 @@ window.document.body.children.length === 1;
|
||||
|
||||
This is turned off by default for performance reasons, but is safe to enable.
|
||||
|
||||
Note that we strongly advise against trying to "execute scripts" by mashing together the jsdom and Node global environments (e.g. by doing `global.window = dom.window`), and then executing scripts or test code inside the Node global environment. Instead, you should treat jsdom like you would a browser, and run all scripts and tests that need access to a DOM inside the jsdom environment, using `window.eval` or `runScripts: "dangerously"`. This might require, for example, creating a browserify bundle to execute as a `<script>` element—just like you would in a browser.
|
||||
(Note that in the default configuration, without setting `runScripts`, the values of `window.Array`, `window.eval`, etc. will be the same as those provided by the outer Node.js environment. That is, `window.eval === eval` will hold, so `window.eval` will not run scripts in a useful way.)
|
||||
|
||||
Finally, for advanced use cases you can use the `dom.runVMScript(script)` method, documented below.
|
||||
We strongly advise against trying to "execute scripts" by mashing together the jsdom and Node global environments (e.g. by doing `global.window = dom.window`), and then executing scripts or test code inside the Node global environment. Instead, you should treat jsdom like you would a browser, and run all scripts and tests that need access to a DOM inside the jsdom environment, using `window.eval` or `runScripts: "dangerously"`. This might require, for example, creating a browserify bundle to execute as a `<script>` element—just like you would in a browser.
|
||||
|
||||
Finally, for advanced use cases you can use the `dom.getInternalVMContext()` method, documented below.
|
||||
|
||||
### Pretending to be a visual browser
|
||||
|
||||
@@ -130,14 +128,68 @@ Note that jsdom still [does not do any layout or rendering](#unimplemented-parts
|
||||
|
||||
### Loading subresources
|
||||
|
||||
#### Basic options
|
||||
|
||||
By default, jsdom will not load any subresources such as scripts, stylesheets, images, or iframes. If you'd like jsdom to load such resources, you can pass the `resources: "usable"` option, which will load all usable resources. Those are:
|
||||
|
||||
* Frames and iframes, via `<frame>` and `<iframe>`
|
||||
* Stylesheets, via `<link rel="stylesheet">`
|
||||
* Scripts, via `<script>`, but only if `runScripts: "dangerously"` is also set
|
||||
* Images, via `<img>`, but only if the `canvas` (or `canvas-prebuilt`) npm package is also installed (see "Canvas Support" below)
|
||||
* Images, via `<img>`, but only if the `canvas` npm package is also installed (see "[Canvas Support](#canvas-support)" below)
|
||||
|
||||
In the future we plan to offer more customization of resource loading via this option, but for now the default and the `"usable"` option are the two modes offered.
|
||||
When attempting to load resources, recall that the default value for the `url` option is `"about:blank"`, which means that any resources included via relative URLs will fail to load. (The result of trying to parse the URL `/something` against the URL `about:blank` is an error.) So, you'll likely want to set a non-default value for the `url` option in those cases, or use one of the [convenience APIs](#convenience-apis) that do so automatically.
|
||||
|
||||
#### Advanced configuration
|
||||
|
||||
_This resource loader system is new as of jsdom v12.0.0, and we'd love your feedback on whether it meets your needs and how easy it is to use. Please file an issue to discuss!_
|
||||
|
||||
To more fully customize jsdom's resource-loading behavior, you can pass an instance of the `ResourceLoader` class as the `resources` option value:
|
||||
|
||||
```js
|
||||
const resourceLoader = new jsdom.ResourceLoader({
|
||||
proxy: "http://127.0.0.1:9001",
|
||||
strictSSL: false,
|
||||
userAgent: "Mellblomenator/9000",
|
||||
});
|
||||
const dom = new JSDOM(``, { resources: resourceLoader });
|
||||
```
|
||||
|
||||
The three options to the `ResourceLoader` constructor are:
|
||||
|
||||
- `proxy` is the address of an HTTP proxy to be used.
|
||||
- `strictSSL` can be set to false to disable the requirement that SSL certificates be valid.
|
||||
- `userAgent` affects the `User-Agent` header sent, and thus the resulting value for `navigator.userAgent`. It defaults to <code>\`Mozilla/5.0 (${process.platform || "unknown OS"}) AppleWebKit/537.36 (KHTML, like Gecko) jsdom/${jsdomVersion}\`</code>.
|
||||
|
||||
You can further customize resource fetching by subclassing `ResourceLoader` and overriding the `fetch()` method. For example, here is a version that only returns results for requests to a trusted origin:
|
||||
|
||||
```js
|
||||
class CustomResourceLoader extends jsdom.ResourceLoader {
|
||||
fetch(url, options) {
|
||||
// Override the contents of this script to do something unusual.
|
||||
if (url === "https://example.com/some-specific-script.js") {
|
||||
return Promise.resolve(Buffer.from("window.someGlobal = 5;"));
|
||||
}
|
||||
|
||||
return super.fetch(url, options);
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
jsdom will call your custom resource loader's `fetch()` method whenever it encounters a "usable" resource, per the above section. The method takes a URL string, as well as a few options which you should pass through unmodified if calling `super.fetch()`. It must return a promise for a Node.js `Buffer` object, or return `null` if the resource is intentionally not to be loaded. In general, most cases will want to delegate to `super.fetch()`, as shown.
|
||||
|
||||
One of the options you will receive in `fetch()` will be the element (if applicable) that is fetching a resource.
|
||||
|
||||
```js
|
||||
class CustomResourceLoader extends jsdom.ResourceLoader {
|
||||
fetch(url, options) {
|
||||
if (options.element) {
|
||||
console.log(`Element ${options.element.localName} is requesting the url ${url}`);
|
||||
}
|
||||
|
||||
return super.fetch(url, options);
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
### Virtual consoles
|
||||
|
||||
@@ -174,7 +226,7 @@ There is also a special event, `"jsdomError"`, which will fire with error object
|
||||
- Script execution errors that are not handled by a window `onerror` event handler that returns `true` or calls `event.preventDefault()`
|
||||
- Not-implemented errors resulting from calls to methods, like `window.alert`, which jsdom does not implement, but installs anyway for web compatibility
|
||||
|
||||
If you're using `sendTo(c)` to send errors to `c`, by default it will call `console.error` with information from `"jsdomError"` events. If you'd prefer to maintain a strict one-to-one mapping of events to method calls, and perhaps handle `"jsdomError"`s yourself, then you can do
|
||||
If you're using `sendTo(c)` to send errors to `c`, by default it will call `c.error(errorStack[, errorDetail])` with information from `"jsdomError"` events. If you'd prefer to maintain a strict one-to-one mapping of events to method calls, and perhaps handle `"jsdomError"`s yourself, then you can do
|
||||
|
||||
```js
|
||||
virtualConsole.sendTo(c, { omitJSDOMErrors: true });
|
||||
@@ -259,15 +311,17 @@ console.log(dom.nodeLocation(imgEl)); // { startOffset: 13, endOffset: 32 }
|
||||
|
||||
Note that this feature only works if you have set the `includeNodeLocations` option; node locations are off by default for performance reasons.
|
||||
|
||||
### Running vm-created scripts with `runVMScript(script)`
|
||||
### Interfacing with the Node.js `vm` module using `getInternalVMContext()`
|
||||
|
||||
The built-in `vm` module of Node.js allows you to create `Script` instances, which can be compiled ahead of time and then run multiple times on a given "VM context". Behind the scenes, a jsdom `Window` is indeed a VM context. To get access to this ability, use the `runVMScript()` method:
|
||||
The built-in [`vm`](https://nodejs.org/api/vm.html) module of Node.js is what underpins jsdom's script-running magic. Some advanced use cases, like pre-compiling a script and then running it multiple times, benefit from using the `vm` module directly with a jsdom-created `Window`.
|
||||
|
||||
To get access to the [contextified global object](https://nodejs.org/api/vm.html#vm_what_does_it_mean_to_contextify_an_object), suitable for use with the `vm` APIs, you can use the `getInternalVMContext()` method:
|
||||
|
||||
```js
|
||||
const { Script } = require("vm");
|
||||
|
||||
const dom = new JSDOM(``, { runScripts: "outside-only" });
|
||||
const s = new Script(`
|
||||
const script = new Script(`
|
||||
if (!this.ran) {
|
||||
this.ran = 0;
|
||||
}
|
||||
@@ -275,15 +329,19 @@ const s = new Script(`
|
||||
++this.ran;
|
||||
`);
|
||||
|
||||
dom.runVMScript(s);
|
||||
dom.runVMScript(s);
|
||||
dom.runVMScript(s);
|
||||
const vmContext = dom.getInternalVMContext();
|
||||
|
||||
dom.window.ran === 3;
|
||||
script.runInContext(vmContext);
|
||||
script.runInContext(vmContext);
|
||||
script.runInContext(vmContext);
|
||||
|
||||
console.assert(dom.window.ran === 3);
|
||||
```
|
||||
|
||||
This is somewhat-advanced functionality, and we advise sticking to normal DOM APIs (such as `window.eval()` or `document.createElement("script")`) unless you have very specific needs.
|
||||
|
||||
Note that this method will throw an exception if the `JSDOM` instance was created without `runScripts` set, or if you are [using jsdom in a web browser](#running-jsdom-inside-a-web-browser).
|
||||
|
||||
### Reconfiguring the jsdom with `reconfigure(settings)`
|
||||
|
||||
The `top` property on `window` is marked `[Unforgeable]` in the spec, meaning it is a non-configurable own property and thus cannot be overridden or shadowed by normal code running inside the jsdom, even using `Object.defineProperty`.
|
||||
@@ -304,7 +362,7 @@ dom.window.top === myFakeTopForTesting;
|
||||
dom.window.location.href === "https://example.com/";
|
||||
```
|
||||
|
||||
Note that changing the jsdom's URL will impact all APIs that return the current document URL, such as `window.location`, `document.URL`, and `document.documentURI`, as well as resolution of relative URLs within the document, and the same-origin checks and referrer used while fetching subresources. It will not, however, perform a navigation to the contents of that URL; the contents of the DOM will remain unchanged, and no new instances of `Window`, `Document`, etc. will be created.
|
||||
Note that changing the jsdom's URL will impact all APIs that return the current document URL, such as `window.location`, `document.URL`, and `document.documentURI`, as well as the resolution of relative URLs within the document, and the same-origin checks and referrer used while fetching subresources. It will not, however, perform navigation to the contents of that URL; the contents of the DOM will remain unchanged, and no new instances of `Window`, `Document`, etc. will be created.
|
||||
|
||||
## Convenience APIs
|
||||
|
||||
@@ -324,12 +382,10 @@ The options provided to `fromURL()` are similar to those provided to the `JSDOM`
|
||||
|
||||
- The `url` and `contentType` options cannot be provided.
|
||||
- The `referrer` option is used as the HTTP `Referer` request header of the initial request.
|
||||
- The `userAgent` option is used as the HTTP `User-Agent` request header of any requests.
|
||||
- The `resources` option also affects the initial request; this is useful if you want to, for example, configure a proxy (see above).
|
||||
- The resulting jsdom's URL, content type, and referrer are determined from the response.
|
||||
- Any cookies set via HTTP `Set-Cookie` response headers are stored in the jsdom's cookie jar. Similarly, any cookies already in a supplied cookie jar are sent as HTTP `Cookie` request headers.
|
||||
|
||||
The initial request is not infinitely customizable to the same extent as is possible in a package like [request](https://www.npmjs.com/package/request); `fromURL()` is meant to be a convenience API for the majority of cases. If you need greater control over the initial request, you should perform it yourself, and then use the `JSDOM` constructor manually.
|
||||
|
||||
### `fromFile()`
|
||||
|
||||
Similar to `fromURL()`, jsdom also provides a `fromFile()` factory method for constructing a jsdom from a filename:
|
||||
@@ -345,7 +401,7 @@ The returned promise will fulfill with a `JSDOM` instance if the given file can
|
||||
The options provided to `fromFile()` are similar to those provided to the `JSDOM` constructor, with the following additional defaults:
|
||||
|
||||
- The `url` option will default to a file URL corresponding to the given filename, instead of to `"about:blank"`.
|
||||
- The `contentType` option will default to `"application/xhtml+xml"` if the given filename ends in `.xhtml` or `.xml`; otherwise it will continue to default to `"text/html"`.
|
||||
- The `contentType` option will default to `"application/xhtml+xml"` if the given filename ends in `.xht`, `.xhtml`, or `.xml`; otherwise it will continue to default to `"text/html"`.
|
||||
|
||||
### `fragment()`
|
||||
|
||||
@@ -355,13 +411,13 @@ For the very simplest of cases, you might not need a whole `JSDOM` instance with
|
||||
const frag = JSDOM.fragment(`<p>Hello</p><p><strong>Hi!</strong>`);
|
||||
|
||||
frag.childNodes.length === 2;
|
||||
frag.querySelector("strong").textContent = "Why hello there!";
|
||||
frag.querySelector("strong").textContent === "Hi!";
|
||||
// etc.
|
||||
```
|
||||
|
||||
Here `frag` is a [`DocumentFragment`](https://developer.mozilla.org/en-US/docs/Web/API/DocumentFragment) instance, whose contents are created by parsing the provided string. The parsing is done using a `<template>` element, so you can include any element there (including ones with weird parsing rules like `<td>`).
|
||||
Here `frag` is a [`DocumentFragment`](https://developer.mozilla.org/en-US/docs/Web/API/DocumentFragment) instance, whose contents are created by parsing the provided string. The parsing is done using a `<template>` element, so you can include any element there (including ones with weird parsing rules like `<td>`). It's also important to note that the resulting `DocumentFragment` will not have [an associated browsing context](https://html.spec.whatwg.org/multipage/#concept-document-bc): that is, elements' `ownerDocument` will have a null `defaultView` property, resources will not load, etc.
|
||||
|
||||
All invocations of the `fragment()` factory result in `DocumentFragment`s that share the same owner `Document` and `Window`. This allows many calls to `fragment()` with no extra overhead. But it also means that calls to `fragment()` cannot be customized with any options.
|
||||
All invocations of the `fragment()` factory result in `DocumentFragment`s that share the same template owner `Document`. This allows many calls to `fragment()` with no extra overhead. But it also means that calls to `fragment()` cannot be customized with any options.
|
||||
|
||||
Note that serialization is not as easy with `DocumentFragment`s as it is with full `JSDOM` objects. If you need to serialize your DOM, you should probably use the `JSDOM` constructor more directly. But for the special case of a fragment containing a single element, it's pretty easy to do through normal means:
|
||||
|
||||
@@ -374,13 +430,15 @@ console.log(frag.firstChild.outerHTML); // logs "<p>Hello</p>"
|
||||
|
||||
### Canvas support
|
||||
|
||||
jsdom includes support for using the [`canvas`](https://www.npmjs.com/package/canvas) or [`canvas-prebuilt`](https://npmjs.org/package/canvas-prebuilt) package to extend any `<canvas>` elements with the canvas API. To make this work, you need to include `canvas` as a dependency in your project, as a peer of `jsdom`. If jsdom can find the `canvas` package, it will use it, but if it's not present, then `<canvas>` elements will behave like `<div>`s.
|
||||
jsdom includes support for using the [`canvas`](https://www.npmjs.com/package/canvas) package to extend any `<canvas>` elements with the canvas API. To make this work, you need to include `canvas` as a dependency in your project, as a peer of `jsdom`. If jsdom can find the `canvas` package, it will use it, but if it's not present, then `<canvas>` elements will behave like `<div>`s. Since jsdom v13, version 2.x of `canvas` is required; version 1.x is no longer supported.
|
||||
|
||||
### Encoding sniffing
|
||||
|
||||
In addition to supplying a string, the `JSDOM` constructor can also be supplied binary data, in the form of a Node.js [`Buffer`](https://nodejs.org/docs/latest/api/buffer.html) or a standard JavaScript binary data type like `ArrayBuffer`, `Uint8Array`, `DataView`, etc. When this is done, jsdom will [sniff the encoding](https://html.spec.whatwg.org/multipage/syntax.html#encoding-sniffing-algorithm) from the supplied bytes, scanning for `<meta charset>` tags just like a browser does.
|
||||
|
||||
This encoding sniffing also applies to `JSDOM.fromFile()` and `JSDOM.fromURL()`. In the latter case, just as in a browser, any `Content-Type` headers sent with the response will take priority.
|
||||
If the supplied `contentType` option contains a `charset` parameter, that encoding will override the sniffed encoding—unless a UTF-8 or UTF-16 BOM is present, in which case those take precedence. (Again, this is just like a browser.)
|
||||
|
||||
This encoding sniffing also applies to `JSDOM.fromFile()` and `JSDOM.fromURL()`. In the latter case, any `Content-Type` headers sent with the response will take priority, in the same fashion as the constructor's `contentType` option.
|
||||
|
||||
Note that in many cases supplying bytes in this fashion can be better than supplying a string. For example, if you attempt to use Node.js's `buffer.toString("utf-8")` API, Node.js will not strip any leading BOMs. If you then give this string to jsdom, it will interpret it verbatim, leaving the BOM intact. But jsdom's binary data decoding code will strip leading BOMs, just like a browser; in such cases, supplying `buffer` directly will give the desired result.
|
||||
|
||||
@@ -394,7 +452,7 @@ If you want to be sure to shut down a jsdom window, use `window.close()`, which
|
||||
|
||||
jsdom has some support for being run inside a web browser, using [browserify](https://browserify.org/). That is, inside a web browser, you can use a browserified jsdom to create an entirely self-contained set of plain JavaScript objects which look and act much like the browser's existing DOM objects, while being entirely independent of them. "Virtual DOM", indeed!
|
||||
|
||||
jsdom's primary target is still Node.js, and so we use language features that are only present in recent Node.js versions (namely, Node.js v6+). Thus, older browsers will likely not work. (Even transpilation will not help much: we plan to use `Proxy`s extensively throughout the course of jsdom v10.x.)
|
||||
jsdom's primary target is still Node.js, and so we use language features that are only present in recent Node.js versions (namely, Node.js v8+). Thus, older browsers will likely not work. (Even transpilation will not help: we use `Proxy`s extensively throughout the jsdom codebase.)
|
||||
|
||||
Notably, jsdom works well inside a web worker. The original contributor, [@lawnsea](https://github.com/lawnsea/), who made this possible, has [published a paper](https://pdfs.semanticscholar.org/47f0/6bb6607a975500a30e9e52d7c9fbc0034e27.pdf) about his project which uses this capability.
|
||||
|
||||
@@ -410,7 +468,7 @@ By default jsdom elements are formatted as plain old JS objects in the console.
|
||||
|
||||
### Asynchronous script loading
|
||||
|
||||
People often have trouble with asynchronous script loading when using jsdom. Many pages loads scripts asynchronously, but there is no way to tell when they're done doing so, and thus when it's a good time to run your code and inspect the resulting DOM structure. This is a fundamental limitation; we cannot predict what scripts on the web page will do, and so cannot tell you when they are done loading more scripts.
|
||||
People often have trouble with asynchronous script loading when using jsdom. Many pages load scripts asynchronously, but there is no way to tell when they're done doing so, and thus when it's a good time to run your code and inspect the resulting DOM structure. This is a fundamental limitation; we cannot predict what scripts on the web page will do, and so cannot tell you when they are done loading more scripts.
|
||||
|
||||
This can be worked around in a few ways. The best way, if you control the page in question, is to use whatever mechanisms are given by the script loader to detect when loading is done. For example, if you're using a module loader like RequireJS, the code could look like:
|
||||
|
||||
@@ -433,31 +491,7 @@ requirejs(["entry-module"], () => {
|
||||
|
||||
If you do not control the page, you could try workarounds such as polling for the presence of a specific element.
|
||||
|
||||
For more details, see the discussion in [#640](https://github.com/tmpvar/jsdom/issues/640), especially [@matthewkastor](https://github.com/matthewkastor)'s [insightful comment](https://github.com/tmpvar/jsdom/issues/640#issuecomment-22216965).
|
||||
|
||||
### Shared constructors and prototypes
|
||||
|
||||
At the present time, for most web platform APIs, jsdom shares the same class definition between multiple seemingly-independent jsdoms. That means that, for example, the following situation can occur:
|
||||
|
||||
```js
|
||||
const dom1 = new JSDOM();
|
||||
const dom2 = new JSDOM();
|
||||
|
||||
dom1.window.Element.prototype.expando = "blah";
|
||||
console.log(dom2.window.document.createElement("frameset").expando); // logs "blah"
|
||||
```
|
||||
|
||||
This is done mainly for performance and memory reasons: creating separate copies of all the many classes on the web platform, each time we create a jsdom, would be rather expensive.
|
||||
|
||||
Nevertheless, we remain interested in one day providing an option to create an "independent" jsdom, at the cost of some performance.
|
||||
|
||||
### Missing features in the new API
|
||||
|
||||
Compared to the old jsdom API from v9.x and before, the new API is noticeably missing fine-grained control of resource loads. Previous versions of jsdom allowed you to set options that were used when making requests (both for the initial request, in the old equivalent of `JSDOM.fromURL()`, and for subresource requests). They also allowed you to control which subresources were requested and applied to the main document, so that you could e.g. download stylesheets but not scripts. Finally, they provided a customizable resource loader that let you intercept any outgoing request and fulfill it with a completely synthetic response.
|
||||
|
||||
None of these features are yet in the new jsdom API, although we are hoping to add them back soon! This requires a decent amount of behind-the-scenes work to implement in a reasonable way, unfortunately.
|
||||
|
||||
In the meantime, please feel free to use the old jsdom API to get access to this functionality. It is supported and maintained, although it will not be getting new features. The documentation is found in [lib/old-api.md](./lib/old-api.md).
|
||||
For more details, see the discussion in [#640](https://github.com/jsdom/jsdom/issues/640), especially [@matthewkastor](https://github.com/matthewkastor)'s [insightful comment](https://github.com/jsdom/jsdom/issues/640#issuecomment-22216965).
|
||||
|
||||
### Unimplemented parts of the web platform
|
||||
|
||||
@@ -470,12 +504,19 @@ Beyond just features that we haven't gotten to yet, there are two major features
|
||||
|
||||
Currently jsdom has dummy behaviors for some aspects of these features, such as sending a "not implemented" `"jsdomError"` to the virtual console for navigation, or returning zeros for many layout-related properties. Often you can work around these limitations in your code, e.g. by creating new `JSDOM` instances for each page you "navigate" to during a crawl, or using `Object.defineProperty()` to change what various layout-related getters and methods return.
|
||||
|
||||
Note that other tools in the same space, such as PhantomJS, do support these features. On the wiki, we have a more complete writeup about [jsdom vs. PhantomJS](https://github.com/tmpvar/jsdom/wiki/jsdom-vs.-PhantomJS).
|
||||
Note that other tools in the same space, such as PhantomJS, do support these features. On the wiki, we have a more complete writeup about [jsdom vs. PhantomJS](https://github.com/jsdom/jsdom/wiki/jsdom-vs.-PhantomJS).
|
||||
|
||||
## Supporting jsdom
|
||||
|
||||
jsdom is a community-driven project maintained by a team of [volunteers](https://github.com/orgs/jsdom/people). You could support jsdom by:
|
||||
|
||||
- [Getting professional support for jsdom](https://tidelift.com/subscription/pkg/npm-jsdom?utm_source=npm-jsdom&utm_medium=referral&utm_campaign=readme) as part of a Tidelift subscription. Tidelift helps making open source sustainable for us while giving teams assurances for maintenance, licensing, and security.
|
||||
- [Contributing](https://github.com/jsdom/jsdom/blob/master/Contributing.md) directly to the project.
|
||||
|
||||
## Getting help
|
||||
|
||||
If you need help with jsdom, please feel free to use any of the following venues:
|
||||
|
||||
- The [mailing list](http://groups.google.com/group/jsdom) (best for "how do I" questions)
|
||||
- The [issue tracker](https://github.com/tmpvar/jsdom/issues) (best for bug reports)
|
||||
- The [issue tracker](https://github.com/jsdom/jsdom/issues) (best for bug reports)
|
||||
- The IRC channel: [#jsdom on freenode](irc://irc.freenode.net/jsdom)
|
||||
|
||||
194
node_modules/jsdom/lib/api.js
generated
vendored
194
node_modules/jsdom/lib/api.js
generated
vendored
@@ -1,9 +1,8 @@
|
||||
"use strict";
|
||||
const path = require("path");
|
||||
const fs = require("pn/fs");
|
||||
const fs = require("fs").promises;
|
||||
const vm = require("vm");
|
||||
const toughCookie = require("tough-cookie");
|
||||
const request = require("request-promise-native");
|
||||
const sniffHTMLEncoding = require("html-encoding-sniffer");
|
||||
const whatwgURL = require("whatwg-url");
|
||||
const whatwgEncoding = require("whatwg-encoding");
|
||||
@@ -11,17 +10,11 @@ const { URL } = require("whatwg-url");
|
||||
const MIMEType = require("whatwg-mimetype");
|
||||
const idlUtils = require("./jsdom/living/generated/utils.js");
|
||||
const VirtualConsole = require("./jsdom/virtual-console.js");
|
||||
const Window = require("./jsdom/browser/Window.js");
|
||||
const { domToHtml } = require("./jsdom/browser/domtohtml.js");
|
||||
const { applyDocumentFeatures } = require("./jsdom/browser/documentfeatures.js");
|
||||
const { wrapCookieJarForRequest } = require("./jsdom/browser/resource-loader.js");
|
||||
const { version: packageVersion } = require("../package.json");
|
||||
|
||||
const DEFAULT_USER_AGENT = `Mozilla/5.0 (${process.platform}) AppleWebKit/537.36 (KHTML, like Gecko) ` +
|
||||
`jsdom/${packageVersion}`;
|
||||
|
||||
// This symbol allows us to smuggle a non-public option through to the JSDOM constructor, for use by JSDOM.fromURL.
|
||||
const transportLayerEncodingLabelHiddenOption = Symbol("transportLayerEncodingLabel");
|
||||
const { createWindow } = require("./jsdom/browser/Window.js");
|
||||
const { parseIntoDocument } = require("./jsdom/browser/parser");
|
||||
const { fragmentSerialization } = require("./jsdom/living/domparsing/serialization.js");
|
||||
const ResourceLoader = require("./jsdom/browser/resources/resource-loader.js");
|
||||
const NoOpResourceLoader = require("./jsdom/browser/resources/no-op-resource-loader.js");
|
||||
|
||||
class CookieJar extends toughCookie.CookieJar {
|
||||
constructor(store, options) {
|
||||
@@ -35,42 +28,25 @@ let sharedFragmentDocument = null;
|
||||
|
||||
class JSDOM {
|
||||
constructor(input, options = {}) {
|
||||
const { html, encoding } = normalizeHTML(input, options[transportLayerEncodingLabelHiddenOption]);
|
||||
options = transformOptions(options, encoding);
|
||||
const mimeType = new MIMEType(options.contentType === undefined ? "text/html" : options.contentType);
|
||||
const { html, encoding } = normalizeHTML(input, mimeType);
|
||||
|
||||
this[window] = new Window(options.windowOptions);
|
||||
options = transformOptions(options, encoding, mimeType);
|
||||
|
||||
// TODO NEWAPI: the whole "features" infrastructure is horrible and should be re-built. When we switch to newapi
|
||||
// wholesale, or perhaps before, we should re-do it. For now, just adapt the new, nice, public API into the old,
|
||||
// ugly, internal API.
|
||||
const features = {
|
||||
FetchExternalResources: [],
|
||||
SkipExternalResources: false
|
||||
};
|
||||
|
||||
if (options.resources === "usable") {
|
||||
features.FetchExternalResources = ["link", "img", "frame", "iframe"];
|
||||
if (options.windowOptions.runScripts === "dangerously") {
|
||||
features.FetchExternalResources.push("script");
|
||||
}
|
||||
|
||||
// Note that "img" will be ignored by the code in HTMLImageElement-impl.js if canvas is not installed.
|
||||
// TODO NEWAPI: clean that up and centralize the logic here.
|
||||
}
|
||||
this[window] = createWindow(options.windowOptions);
|
||||
|
||||
const documentImpl = idlUtils.implForWrapper(this[window]._document);
|
||||
applyDocumentFeatures(documentImpl, features);
|
||||
|
||||
options.beforeParse(this[window]._globalProxy);
|
||||
|
||||
// TODO NEWAPI: this is still pretty hacky. It's also different than jsdom.jsdom. Does it work? Can it be better?
|
||||
documentImpl._htmlToDom.appendToDocument(html, documentImpl);
|
||||
parseIntoDocument(html, documentImpl);
|
||||
|
||||
documentImpl.close();
|
||||
}
|
||||
|
||||
get window() {
|
||||
// It's important to grab the global proxy, instead of just the result of `new Window(...)`, since otherwise things
|
||||
// like `window.eval` don't exist.
|
||||
// It's important to grab the global proxy, instead of just the result of `createWindow(...)`, since otherwise
|
||||
// things like `window.eval` don't exist.
|
||||
return this[window]._globalProxy;
|
||||
}
|
||||
|
||||
@@ -84,24 +60,24 @@ class JSDOM {
|
||||
}
|
||||
|
||||
serialize() {
|
||||
return domToHtml([idlUtils.implForWrapper(this[window]._document)]);
|
||||
return fragmentSerialization(idlUtils.implForWrapper(this[window]._document), { requireWellFormed: false });
|
||||
}
|
||||
|
||||
nodeLocation(node) {
|
||||
if (!idlUtils.implForWrapper(this[window]._document)._parseOptions.locationInfo) {
|
||||
if (!idlUtils.implForWrapper(this[window]._document)._parseOptions.sourceCodeLocationInfo) {
|
||||
throw new Error("Location information was not saved for this jsdom. Use includeNodeLocations during creation.");
|
||||
}
|
||||
|
||||
return idlUtils.implForWrapper(node).__location;
|
||||
return idlUtils.implForWrapper(node).sourceCodeLocation;
|
||||
}
|
||||
|
||||
runVMScript(script) {
|
||||
getInternalVMContext() {
|
||||
if (!vm.isContext(this[window])) {
|
||||
throw new TypeError("This jsdom was not configured to allow script running. " +
|
||||
"Use the runScripts option during creation.");
|
||||
}
|
||||
|
||||
return script.runInContext(this[window]);
|
||||
return this[window];
|
||||
}
|
||||
|
||||
reconfigure(settings) {
|
||||
@@ -118,11 +94,11 @@ class JSDOM {
|
||||
}
|
||||
|
||||
document._URL = url;
|
||||
document.origin = whatwgURL.serializeURLOrigin(document._URL);
|
||||
document._origin = whatwgURL.serializeURLOrigin(document._URL);
|
||||
}
|
||||
}
|
||||
|
||||
static fragment(string) {
|
||||
static fragment(string = "") {
|
||||
if (!sharedFragmentDocument) {
|
||||
sharedFragmentDocument = (new JSDOM()).window.document;
|
||||
}
|
||||
@@ -134,50 +110,45 @@ class JSDOM {
|
||||
|
||||
static fromURL(url, options = {}) {
|
||||
return Promise.resolve().then(() => {
|
||||
// Remove the hash while sending this through the research loader fetch().
|
||||
// It gets added back a few lines down when constructing the JSDOM object.
|
||||
const parsedURL = new URL(url);
|
||||
const originalHash = parsedURL.hash;
|
||||
parsedURL.hash = "";
|
||||
url = parsedURL.href;
|
||||
|
||||
options = normalizeFromURLOptions(options);
|
||||
|
||||
const requestOptions = {
|
||||
resolveWithFullResponse: true,
|
||||
encoding: null, // i.e., give me the raw Buffer
|
||||
gzip: true,
|
||||
headers: {
|
||||
"User-Agent": options.userAgent,
|
||||
Referer: options.referrer,
|
||||
Accept: "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8",
|
||||
"Accept-Language": "en"
|
||||
},
|
||||
jar: wrapCookieJarForRequest(options.cookieJar)
|
||||
};
|
||||
const resourceLoader = resourcesToResourceLoader(options.resources);
|
||||
const resourceLoaderForInitialRequest = resourceLoader.constructor === NoOpResourceLoader ?
|
||||
new ResourceLoader() :
|
||||
resourceLoader;
|
||||
|
||||
return request(url, requestOptions).then(res => {
|
||||
let transportLayerEncodingLabel;
|
||||
if ("content-type" in res.headers) {
|
||||
const mimeType = new MIMEType(res.headers["content-type"]);
|
||||
transportLayerEncodingLabel = mimeType.parameters.get("charset");
|
||||
}
|
||||
const req = resourceLoaderForInitialRequest.fetch(url, {
|
||||
accept: "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8",
|
||||
cookieJar: options.cookieJar,
|
||||
referrer: options.referrer
|
||||
});
|
||||
|
||||
return req.then(body => {
|
||||
const res = req.response;
|
||||
|
||||
options = Object.assign(options, {
|
||||
url: res.request.href + parsedURL.hash,
|
||||
url: req.href + originalHash,
|
||||
contentType: res.headers["content-type"],
|
||||
referrer: res.request.getHeader("referer"),
|
||||
[transportLayerEncodingLabelHiddenOption]: transportLayerEncodingLabel
|
||||
referrer: req.getHeader("referer")
|
||||
});
|
||||
|
||||
return new JSDOM(res.body, options);
|
||||
return new JSDOM(body, options);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
static fromFile(filename, options = {}) {
|
||||
return Promise.resolve().then(() => {
|
||||
options = normalizeFromFileOptions(filename, options);
|
||||
static async fromFile(filename, options = {}) {
|
||||
options = normalizeFromFileOptions(filename, options);
|
||||
const buffer = await fs.readFile(filename);
|
||||
|
||||
return fs.readFile(filename).then(buffer => {
|
||||
return new JSDOM(buffer, options);
|
||||
});
|
||||
});
|
||||
return new JSDOM(buffer, options);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -193,9 +164,6 @@ function normalizeFromURLOptions(options) {
|
||||
// Normalization of options which must be done before the rest of the fromURL code can use them, because they are
|
||||
// given to request()
|
||||
const normalized = Object.assign({}, options);
|
||||
if (options.userAgent === undefined) {
|
||||
normalized.userAgent = DEFAULT_USER_AGENT;
|
||||
}
|
||||
|
||||
if (options.referrer !== undefined) {
|
||||
normalized.referrer = (new URL(options.referrer)).href;
|
||||
@@ -216,7 +184,7 @@ function normalizeFromFileOptions(filename, options) {
|
||||
|
||||
if (normalized.contentType === undefined) {
|
||||
const extname = path.extname(filename);
|
||||
if (extname === ".xhtml" || extname === ".xml") {
|
||||
if (extname === ".xhtml" || extname === ".xht" || extname === ".xml") {
|
||||
normalized.contentType = "application/xhtml+xml";
|
||||
}
|
||||
}
|
||||
@@ -228,7 +196,7 @@ function normalizeFromFileOptions(filename, options) {
|
||||
return normalized;
|
||||
}
|
||||
|
||||
function transformOptions(options, encoding) {
|
||||
function transformOptions(options, encoding, mimeType) {
|
||||
const transformed = {
|
||||
windowOptions: {
|
||||
// Defaults
|
||||
@@ -236,34 +204,33 @@ function transformOptions(options, encoding) {
|
||||
referrer: "",
|
||||
contentType: "text/html",
|
||||
parsingMode: "html",
|
||||
userAgent: DEFAULT_USER_AGENT,
|
||||
parseOptions: { locationInfo: false },
|
||||
parseOptions: {
|
||||
sourceCodeLocationInfo: false,
|
||||
scriptingEnabled: false
|
||||
},
|
||||
runScripts: undefined,
|
||||
encoding,
|
||||
pretendToBeVisual: false,
|
||||
storageQuota: 5000000,
|
||||
|
||||
// Defaults filled in later
|
||||
resourceLoader: undefined,
|
||||
virtualConsole: undefined,
|
||||
cookieJar: undefined
|
||||
},
|
||||
|
||||
// Defaults
|
||||
resources: undefined,
|
||||
beforeParse() { }
|
||||
};
|
||||
|
||||
if (options.contentType !== undefined) {
|
||||
const mimeType = new MIMEType(options.contentType);
|
||||
|
||||
if (!mimeType.isHTML() && !mimeType.isXML()) {
|
||||
throw new RangeError(`The given content type of "${options.contentType}" was not a HTML or XML content type`);
|
||||
}
|
||||
|
||||
transformed.windowOptions.contentType = mimeType.essence;
|
||||
transformed.windowOptions.parsingMode = mimeType.isHTML() ? "html" : "xml";
|
||||
// options.contentType was parsed into mimeType by the caller.
|
||||
if (!mimeType.isHTML() && !mimeType.isXML()) {
|
||||
throw new RangeError(`The given content type of "${options.contentType}" was not a HTML or XML content type`);
|
||||
}
|
||||
|
||||
transformed.windowOptions.contentType = mimeType.essence;
|
||||
transformed.windowOptions.parsingMode = mimeType.isHTML() ? "html" : "xml";
|
||||
|
||||
if (options.url !== undefined) {
|
||||
transformed.windowOptions.url = (new URL(options.url)).href;
|
||||
}
|
||||
@@ -272,16 +239,12 @@ function transformOptions(options, encoding) {
|
||||
transformed.windowOptions.referrer = (new URL(options.referrer)).href;
|
||||
}
|
||||
|
||||
if (options.userAgent !== undefined) {
|
||||
transformed.windowOptions.userAgent = String(options.userAgent);
|
||||
}
|
||||
|
||||
if (options.includeNodeLocations) {
|
||||
if (transformed.windowOptions.parsingMode === "xml") {
|
||||
throw new TypeError("Cannot set includeNodeLocations to true with an XML content type");
|
||||
}
|
||||
|
||||
transformed.windowOptions.parseOptions = { locationInfo: true };
|
||||
transformed.windowOptions.parseOptions = { sourceCodeLocationInfo: true };
|
||||
}
|
||||
|
||||
transformed.windowOptions.cookieJar = options.cookieJar === undefined ?
|
||||
@@ -292,17 +255,17 @@ function transformOptions(options, encoding) {
|
||||
(new VirtualConsole()).sendTo(console) :
|
||||
options.virtualConsole;
|
||||
|
||||
if (options.resources !== undefined) {
|
||||
transformed.resources = String(options.resources);
|
||||
if (transformed.resources !== "usable") {
|
||||
throw new RangeError(`resources must be undefined or "usable"`);
|
||||
}
|
||||
if (!(transformed.windowOptions.virtualConsole instanceof VirtualConsole)) {
|
||||
throw new TypeError("virtualConsole must be an instance of VirtualConsole");
|
||||
}
|
||||
|
||||
transformed.windowOptions.resourceLoader = resourcesToResourceLoader(options.resources);
|
||||
|
||||
if (options.runScripts !== undefined) {
|
||||
transformed.windowOptions.runScripts = String(options.runScripts);
|
||||
if (transformed.windowOptions.runScripts !== "dangerously" &&
|
||||
transformed.windowOptions.runScripts !== "outside-only") {
|
||||
if (transformed.windowOptions.runScripts === "dangerously") {
|
||||
transformed.windowOptions.parseOptions.scriptingEnabled = true;
|
||||
} else if (transformed.windowOptions.runScripts !== "outside-only") {
|
||||
throw new RangeError(`runScripts must be undefined, "dangerously", or "outside-only"`);
|
||||
}
|
||||
}
|
||||
@@ -324,7 +287,7 @@ function transformOptions(options, encoding) {
|
||||
return transformed;
|
||||
}
|
||||
|
||||
function normalizeHTML(html = "", transportLayerEncodingLabel) {
|
||||
function normalizeHTML(html = "", mimeType) {
|
||||
let encoding = "UTF-8";
|
||||
|
||||
if (ArrayBuffer.isView(html)) {
|
||||
@@ -334,7 +297,10 @@ function normalizeHTML(html = "", transportLayerEncodingLabel) {
|
||||
}
|
||||
|
||||
if (Buffer.isBuffer(html)) {
|
||||
encoding = sniffHTMLEncoding(html, { defaultEncoding: "windows-1252", transportLayerEncodingLabel });
|
||||
encoding = sniffHTMLEncoding(html, {
|
||||
defaultEncoding: mimeType.isXML() ? "UTF-8" : "windows-1252",
|
||||
transportLayerEncodingLabel: mimeType.parameters.get("charset")
|
||||
});
|
||||
html = whatwgEncoding.decode(html, encoding);
|
||||
} else {
|
||||
html = String(html);
|
||||
@@ -343,9 +309,27 @@ function normalizeHTML(html = "", transportLayerEncodingLabel) {
|
||||
return { html, encoding };
|
||||
}
|
||||
|
||||
function resourcesToResourceLoader(resources) {
|
||||
switch (resources) {
|
||||
case undefined: {
|
||||
return new NoOpResourceLoader();
|
||||
}
|
||||
case "usable": {
|
||||
return new ResourceLoader();
|
||||
}
|
||||
default: {
|
||||
if (!(resources instanceof ResourceLoader)) {
|
||||
throw new TypeError("resources must be an instance of ResourceLoader");
|
||||
}
|
||||
return resources;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
exports.JSDOM = JSDOM;
|
||||
|
||||
exports.VirtualConsole = VirtualConsole;
|
||||
exports.CookieJar = CookieJar;
|
||||
exports.ResourceLoader = ResourceLoader;
|
||||
|
||||
exports.toughCookie = toughCookie;
|
||||
|
||||
681
node_modules/jsdom/lib/jsdom/browser/Window.js
generated
vendored
681
node_modules/jsdom/lib/jsdom/browser/Window.js
generated
vendored
@@ -1,113 +1,147 @@
|
||||
"use strict";
|
||||
|
||||
const vm = require("vm");
|
||||
const webIDLConversions = require("webidl-conversions");
|
||||
const { CSSStyleDeclaration } = require("cssstyle");
|
||||
const { Performance: RawPerformance } = require("w3c-hr-time");
|
||||
const notImplemented = require("./not-implemented");
|
||||
const VirtualConsole = require("../virtual-console");
|
||||
const { installInterfaces } = require("../living/interfaces");
|
||||
const { define, mixin } = require("../utils");
|
||||
const Element = require("../living/generated/Element");
|
||||
const EventTarget = require("../living/generated/EventTarget");
|
||||
const PageTransitionEvent = require("../living/generated/PageTransitionEvent");
|
||||
const namedPropertiesWindow = require("../living/named-properties-window");
|
||||
const cssom = require("cssom");
|
||||
const postMessage = require("../living/post-message");
|
||||
const DOMException = require("domexception");
|
||||
const DOMException = require("domexception/webidl2js-wrapper");
|
||||
const { btoa, atob } = require("abab");
|
||||
const idlUtils = require("../living/generated/utils");
|
||||
const createXMLHttpRequest = require("../living/xmlhttprequest");
|
||||
const createFileReader = require("../living/generated/FileReader").createInterface;
|
||||
const createWebSocket = require("../living/generated/WebSocket").createInterface;
|
||||
const WebSocketImpl = require("../living/websockets/WebSocket-impl").implementation;
|
||||
const BarProp = require("../living/generated/BarProp");
|
||||
const Document = require("../living/generated/Document");
|
||||
const documents = require("../living/documents.js");
|
||||
const External = require("../living/generated/External");
|
||||
const Navigator = require("../living/generated/Navigator");
|
||||
const Performance = require("../living/generated/Performance");
|
||||
const Screen = require("../living/generated/Screen");
|
||||
const Storage = require("../living/generated/Storage");
|
||||
const createAbortController = require("../living/generated/AbortController").createInterface;
|
||||
const createAbortSignal = require("../living/generated/AbortSignal").createInterface;
|
||||
const Selection = require("../living/generated/Selection");
|
||||
const reportException = require("../living/helpers/runtime-script-errors");
|
||||
const { matchesDontThrow } = require("../living/helpers/selectors");
|
||||
const { fireAnEvent } = require("../living/helpers/events");
|
||||
const SessionHistory = require("../living/window/SessionHistory");
|
||||
const { contextifyWindow } = require("./documentfeatures.js");
|
||||
const { forEachMatchingSheetRuleOfElement, getResolvedValue, propertiesWithResolvedValueImplemented,
|
||||
SHADOW_DOM_PSEUDO_REGEXP } = require("../living/helpers/style-rules.js");
|
||||
const CustomElementRegistry = require("../living/generated/CustomElementRegistry");
|
||||
const jsGlobals = require("./js-globals.json");
|
||||
|
||||
const GlobalEventHandlersImpl = require("../living/nodes/GlobalEventHandlers-impl").implementation;
|
||||
const WindowEventHandlersImpl = require("../living/nodes/WindowEventHandlers-impl").implementation;
|
||||
|
||||
// NB: the require() must be after assigning `module.exports` because this require() is circular
|
||||
// TODO: this above note might not even be true anymore... figure out the cycle and document it, or clean up.
|
||||
module.exports = Window;
|
||||
const dom = require("../living");
|
||||
exports.createWindow = function (options) {
|
||||
return new Window(options);
|
||||
};
|
||||
|
||||
const cssSelectorSplitRE = /((?:[^,"']|"[^"]*"|'[^']*')+)/;
|
||||
const jsGlobalEntriesToInstall = Object.entries(jsGlobals).filter(([name]) => name in global);
|
||||
|
||||
const defaultStyleSheet = cssom.parse(require("./default-stylesheet"));
|
||||
// https://html.spec.whatwg.org/#the-window-object
|
||||
function setupWindow(windowInstance, { runScripts }) {
|
||||
if (runScripts === "outside-only" || runScripts === "dangerously") {
|
||||
contextifyWindow(windowInstance);
|
||||
|
||||
dom.Window = Window;
|
||||
// Without this, these globals will only appear to scripts running inside the context using vm.runScript; they will
|
||||
// not appear to scripts running from the outside, including to JSDOM implementation code.
|
||||
for (const [globalName, globalPropDesc] of jsGlobalEntriesToInstall) {
|
||||
const propDesc = { ...globalPropDesc, value: vm.runInContext(globalName, windowInstance) };
|
||||
Object.defineProperty(windowInstance, globalName, propDesc);
|
||||
}
|
||||
} else {
|
||||
// Without contextifying the window, none of the globals will exist. So, let's at least alias them from the Node.js
|
||||
// context. See https://github.com/jsdom/jsdom/issues/2727 for more background and discussion.
|
||||
for (const [globalName, globalPropDesc] of jsGlobalEntriesToInstall) {
|
||||
const propDesc = { ...globalPropDesc, value: global[globalName] };
|
||||
Object.defineProperty(windowInstance, globalName, propDesc);
|
||||
}
|
||||
}
|
||||
|
||||
installInterfaces(windowInstance, ["Window"]);
|
||||
|
||||
const EventTargetConstructor = windowInstance.EventTarget;
|
||||
|
||||
// eslint-disable-next-line func-name-matching, func-style, no-shadow
|
||||
const windowConstructor = function Window() {
|
||||
throw new TypeError("Illegal constructor");
|
||||
};
|
||||
Object.setPrototypeOf(windowConstructor, EventTargetConstructor);
|
||||
|
||||
Object.defineProperty(windowInstance, "Window", {
|
||||
configurable: true,
|
||||
writable: true,
|
||||
value: windowConstructor
|
||||
});
|
||||
|
||||
const windowPrototype = Object.create(EventTargetConstructor.prototype);
|
||||
Object.defineProperties(windowPrototype, {
|
||||
constructor: {
|
||||
value: windowConstructor,
|
||||
writable: true,
|
||||
configurable: true
|
||||
},
|
||||
[Symbol.toStringTag]: {
|
||||
value: "Window",
|
||||
configurable: true
|
||||
}
|
||||
});
|
||||
|
||||
windowConstructor.prototype = windowPrototype;
|
||||
Object.setPrototypeOf(windowInstance, windowPrototype);
|
||||
|
||||
EventTarget.setup(windowInstance, windowInstance);
|
||||
mixin(windowInstance, WindowEventHandlersImpl.prototype);
|
||||
mixin(windowInstance, GlobalEventHandlersImpl.prototype);
|
||||
windowInstance._initGlobalEvents();
|
||||
|
||||
windowInstance._globalObject = windowInstance;
|
||||
}
|
||||
|
||||
// NOTE: per https://heycam.github.io/webidl/#Global, all properties on the Window object must be own-properties.
|
||||
// That is why we assign everything inside of the constructor, instead of using a shared prototype.
|
||||
// You can verify this in e.g. Firefox or Internet Explorer, which do a good job with Web IDL compliance.
|
||||
|
||||
function Window(options) {
|
||||
EventTarget.setup(this);
|
||||
setupWindow(this, { runScripts: options.runScripts });
|
||||
|
||||
const rawPerformance = new RawPerformance();
|
||||
const windowInitialized = rawPerformance.now();
|
||||
|
||||
const window = this;
|
||||
|
||||
mixin(window, WindowEventHandlersImpl.prototype);
|
||||
mixin(window, GlobalEventHandlersImpl.prototype);
|
||||
|
||||
this._initGlobalEvents();
|
||||
|
||||
///// INTERFACES FROM THE DOM
|
||||
// TODO: consider a mode of some sort where these are not shared between all DOM instances
|
||||
// It'd be very memory-expensive in most cases, though.
|
||||
for (const name in dom) {
|
||||
Object.defineProperty(window, name, {
|
||||
enumerable: false,
|
||||
configurable: true,
|
||||
writable: true,
|
||||
value: dom[name]
|
||||
});
|
||||
}
|
||||
|
||||
///// PRIVATE DATA PROPERTIES
|
||||
|
||||
this._resourceLoader = options.resourceLoader;
|
||||
|
||||
// vm initialization is deferred until script processing is activated
|
||||
this._globalProxy = this;
|
||||
Object.defineProperty(idlUtils.implForWrapper(this), idlUtils.wrapperSymbol, { get: () => this._globalProxy });
|
||||
|
||||
let timers = Object.create(null);
|
||||
let animationFrameCallbacks = Object.create(null);
|
||||
|
||||
// List options explicitly to be clear which are passed through
|
||||
this._document = Document.create([], {
|
||||
options: {
|
||||
parsingMode: options.parsingMode,
|
||||
contentType: options.contentType,
|
||||
encoding: options.encoding,
|
||||
cookieJar: options.cookieJar,
|
||||
url: options.url,
|
||||
lastModified: options.lastModified,
|
||||
referrer: options.referrer,
|
||||
cookie: options.cookie,
|
||||
deferClose: options.deferClose,
|
||||
resourceLoader: options.resourceLoader,
|
||||
concurrentNodeIterators: options.concurrentNodeIterators,
|
||||
pool: options.pool,
|
||||
agent: options.agent,
|
||||
agentClass: options.agentClass,
|
||||
agentOptions: options.agentOptions,
|
||||
strictSSL: options.strictSSL,
|
||||
proxy: options.proxy,
|
||||
parseOptions: options.parseOptions,
|
||||
defaultView: this._globalProxy,
|
||||
global: this
|
||||
}
|
||||
});
|
||||
this._document = documents.createWrapper(window, {
|
||||
parsingMode: options.parsingMode,
|
||||
contentType: options.contentType,
|
||||
encoding: options.encoding,
|
||||
cookieJar: options.cookieJar,
|
||||
url: options.url,
|
||||
lastModified: options.lastModified,
|
||||
referrer: options.referrer,
|
||||
concurrentNodeIterators: options.concurrentNodeIterators,
|
||||
parseOptions: options.parseOptions,
|
||||
defaultView: this._globalProxy,
|
||||
global: this
|
||||
}, { alwaysUseDocumentClass: true });
|
||||
|
||||
if (vm.isContext(window)) {
|
||||
const documentImpl = idlUtils.implForWrapper(window._document);
|
||||
documentImpl._defaultView = window._globalProxy = vm.runInContext("this", window);
|
||||
}
|
||||
|
||||
const documentOrigin = idlUtils.implForWrapper(this._document)._origin;
|
||||
this._origin = documentOrigin;
|
||||
|
||||
// https://html.spec.whatwg.org/#session-history
|
||||
this._sessionHistory = new SessionHistory({
|
||||
document: idlUtils.implForWrapper(this._document),
|
||||
@@ -115,21 +149,9 @@ function Window(options) {
|
||||
stateObject: null
|
||||
}, this);
|
||||
|
||||
// TODO NEWAPI can remove this
|
||||
if (options.virtualConsole) {
|
||||
if (options.virtualConsole instanceof VirtualConsole) {
|
||||
this._virtualConsole = options.virtualConsole;
|
||||
} else {
|
||||
throw new TypeError("options.virtualConsole must be a VirtualConsole (from createVirtualConsole)");
|
||||
}
|
||||
} else {
|
||||
this._virtualConsole = new VirtualConsole();
|
||||
}
|
||||
this._virtualConsole = options.virtualConsole;
|
||||
|
||||
this._runScripts = options.runScripts;
|
||||
if (this._runScripts === "outside-only" || this._runScripts === "dangerously") {
|
||||
contextifyWindow(this);
|
||||
}
|
||||
|
||||
// Set up the window as if it's a top level window.
|
||||
// If it's not, then references will be corrected by frame/iframe code.
|
||||
@@ -147,11 +169,11 @@ function Window(options) {
|
||||
// Some properties (such as localStorage and sessionStorage) share data
|
||||
// between windows in the same origin. This object is intended
|
||||
// to contain such data.
|
||||
if (options.commonForOrigin && options.commonForOrigin[this._document.origin]) {
|
||||
if (options.commonForOrigin && options.commonForOrigin[documentOrigin]) {
|
||||
this._commonForOrigin = options.commonForOrigin;
|
||||
} else {
|
||||
this._commonForOrigin = {
|
||||
[this._document.origin]: {
|
||||
[documentOrigin]: {
|
||||
localStorageArea: new Map(),
|
||||
sessionStorageArea: new Map(),
|
||||
windowsInSameOrigin: [this]
|
||||
@@ -159,18 +181,18 @@ function Window(options) {
|
||||
};
|
||||
}
|
||||
|
||||
this._currentOriginData = this._commonForOrigin[this._document.origin];
|
||||
this._currentOriginData = this._commonForOrigin[documentOrigin];
|
||||
|
||||
///// WEB STORAGE
|
||||
|
||||
this._localStorage = Storage.create([], {
|
||||
this._localStorage = Storage.create(window, [], {
|
||||
associatedWindow: this,
|
||||
storageArea: this._currentOriginData.localStorageArea,
|
||||
type: "localStorage",
|
||||
url: this._document.documentURI,
|
||||
storageQuota: this._storageQuota
|
||||
});
|
||||
this._sessionStorage = Storage.create([], {
|
||||
this._sessionStorage = Storage.create(window, [], {
|
||||
associatedWindow: this,
|
||||
storageArea: this._currentOriginData.sessionStorageArea,
|
||||
type: "sessionStorage",
|
||||
@@ -178,18 +200,29 @@ function Window(options) {
|
||||
storageQuota: this._storageQuota
|
||||
});
|
||||
|
||||
///// SELECTION
|
||||
|
||||
// https://w3c.github.io/selection-api/#dfn-selection
|
||||
this._selection = Selection.createImpl(window);
|
||||
|
||||
// https://w3c.github.io/selection-api/#dom-window
|
||||
this.getSelection = function () {
|
||||
return window._selection;
|
||||
};
|
||||
|
||||
///// GETTERS
|
||||
|
||||
const locationbar = BarProp.create();
|
||||
const menubar = BarProp.create();
|
||||
const personalbar = BarProp.create();
|
||||
const scrollbars = BarProp.create();
|
||||
const statusbar = BarProp.create();
|
||||
const toolbar = BarProp.create();
|
||||
const external = External.create();
|
||||
const navigator = Navigator.create([], { userAgent: options.userAgent });
|
||||
const performance = Performance.create([], { rawPerformance });
|
||||
const screen = Screen.create();
|
||||
const locationbar = BarProp.create(window);
|
||||
const menubar = BarProp.create(window);
|
||||
const personalbar = BarProp.create(window);
|
||||
const scrollbars = BarProp.create(window);
|
||||
const statusbar = BarProp.create(window);
|
||||
const toolbar = BarProp.create(window);
|
||||
const external = External.create(window);
|
||||
const navigator = Navigator.create(window, [], { userAgent: this._resourceLoader._userAgent });
|
||||
const performance = Performance.create(window, [], { rawPerformance });
|
||||
const screen = Screen.create(window);
|
||||
const customElementRegistry = CustomElementRegistry.create(window);
|
||||
|
||||
define(this, {
|
||||
get length() {
|
||||
@@ -199,7 +232,7 @@ function Window(options) {
|
||||
return window._globalProxy;
|
||||
},
|
||||
get frameElement() {
|
||||
return window._frameElement;
|
||||
return idlUtils.wrapperForImpl(window._frameElement);
|
||||
},
|
||||
get frames() {
|
||||
return window._globalProxy;
|
||||
@@ -252,81 +285,206 @@ function Window(options) {
|
||||
get screen() {
|
||||
return screen;
|
||||
},
|
||||
get origin() {
|
||||
return window._origin;
|
||||
},
|
||||
// The origin IDL attribute is defined with [Replaceable].
|
||||
set origin(value) {
|
||||
Object.defineProperty(this, "origin", {
|
||||
value,
|
||||
writable: true,
|
||||
enumerable: true,
|
||||
configurable: true
|
||||
});
|
||||
},
|
||||
get localStorage() {
|
||||
if (this._document.origin === "null") {
|
||||
throw new DOMException("localStorage is not available for opaque origins", "SecurityError");
|
||||
if (idlUtils.implForWrapper(this._document)._origin === "null") {
|
||||
throw DOMException.create(window, [
|
||||
"localStorage is not available for opaque origins",
|
||||
"SecurityError"
|
||||
]);
|
||||
}
|
||||
|
||||
return this._localStorage;
|
||||
},
|
||||
get sessionStorage() {
|
||||
if (this._document.origin === "null") {
|
||||
throw new DOMException("sessionStorage is not available for opaque origins", "SecurityError");
|
||||
if (idlUtils.implForWrapper(this._document)._origin === "null") {
|
||||
throw DOMException.create(window, [
|
||||
"sessionStorage is not available for opaque origins",
|
||||
"SecurityError"
|
||||
]);
|
||||
}
|
||||
|
||||
return this._sessionStorage;
|
||||
},
|
||||
get customElements() {
|
||||
return customElementRegistry;
|
||||
}
|
||||
});
|
||||
|
||||
namedPropertiesWindow.initializeWindow(this, this._globalProxy);
|
||||
|
||||
///// METHODS for [ImplicitThis] hack
|
||||
// See https://lists.w3.org/Archives/Public/public-script-coord/2015JanMar/0109.html
|
||||
this.addEventListener = this.addEventListener.bind(this);
|
||||
this.removeEventListener = this.removeEventListener.bind(this);
|
||||
this.dispatchEvent = this.dispatchEvent.bind(this);
|
||||
|
||||
///// METHODS
|
||||
|
||||
// https://html.spec.whatwg.org/multipage/timers-and-user-prompts.html#timers
|
||||
|
||||
// In the spec the list of active timers is a set of IDs. We make it a map of IDs to Node.js timer objects, so that
|
||||
// we can call Node.js-side clearTimeout() when clearing, and thus allow process shutdown faster.
|
||||
const listOfActiveTimers = new Map();
|
||||
let latestTimerId = 0;
|
||||
let latestAnimationFrameCallbackId = 0;
|
||||
|
||||
this.setTimeout = function (fn, ms) {
|
||||
const args = [];
|
||||
for (let i = 2; i < arguments.length; ++i) {
|
||||
args[i - 2] = arguments[i];
|
||||
this.setTimeout = function (handler, timeout = 0, ...args) {
|
||||
if (typeof handler !== "function") {
|
||||
handler = webIDLConversions.DOMString(handler);
|
||||
}
|
||||
return startTimer(window, setTimeout, clearTimeout, ++latestTimerId, fn, ms, timers, args);
|
||||
timeout = webIDLConversions.long(timeout);
|
||||
|
||||
return timerInitializationSteps(handler, timeout, args, { methodContext: window, repeat: false });
|
||||
};
|
||||
this.setInterval = function (fn, ms) {
|
||||
const args = [];
|
||||
for (let i = 2; i < arguments.length; ++i) {
|
||||
args[i - 2] = arguments[i];
|
||||
this.setInterval = function (handler, timeout = 0, ...args) {
|
||||
if (typeof handler !== "function") {
|
||||
handler = webIDLConversions.DOMString(handler);
|
||||
}
|
||||
return startTimer(window, setInterval, clearInterval, ++latestTimerId, fn, ms, timers, args);
|
||||
timeout = webIDLConversions.long(timeout);
|
||||
|
||||
return timerInitializationSteps(handler, timeout, args, { methodContext: window, repeat: true });
|
||||
};
|
||||
this.clearInterval = stopTimer.bind(this, timers);
|
||||
this.clearTimeout = stopTimer.bind(this, timers);
|
||||
|
||||
if (this._pretendToBeVisual) {
|
||||
this.requestAnimationFrame = fn => {
|
||||
const timestamp = rawPerformance.now() - windowInitialized;
|
||||
const fps = 1000 / 60;
|
||||
this.clearTimeout = function (handle = 0) {
|
||||
handle = webIDLConversions.long(handle);
|
||||
|
||||
return startTimer(
|
||||
window,
|
||||
setTimeout,
|
||||
clearTimeout,
|
||||
++latestAnimationFrameCallbackId,
|
||||
fn,
|
||||
fps,
|
||||
animationFrameCallbacks,
|
||||
[timestamp]
|
||||
);
|
||||
};
|
||||
this.cancelAnimationFrame = stopTimer.bind(this, animationFrameCallbacks);
|
||||
const nodejsTimer = listOfActiveTimers.get(handle);
|
||||
if (nodejsTimer) {
|
||||
clearTimeout(nodejsTimer);
|
||||
listOfActiveTimers.delete(handle);
|
||||
}
|
||||
};
|
||||
this.clearInterval = function (handle = 0) {
|
||||
handle = webIDLConversions.long(handle);
|
||||
|
||||
const nodejsTimer = listOfActiveTimers.get(handle);
|
||||
if (nodejsTimer) {
|
||||
// We use setTimeout() in timerInitializationSteps even for this.setInterval().
|
||||
clearTimeout(nodejsTimer);
|
||||
listOfActiveTimers.delete(handle);
|
||||
}
|
||||
};
|
||||
|
||||
function timerInitializationSteps(handler, timeout, args, { methodContext, repeat, previousHandle }) {
|
||||
// This appears to be unspecced, but matches browser behavior for close()ed windows.
|
||||
if (!methodContext._document) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
// TODO: implement timer nesting level behavior.
|
||||
|
||||
const methodContextProxy = methodContext._globalProxy;
|
||||
const handle = previousHandle !== undefined ? previousHandle : ++latestTimerId;
|
||||
|
||||
function task() {
|
||||
if (!listOfActiveTimers.has(handle)) {
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
if (typeof handler === "function") {
|
||||
handler.apply(methodContextProxy, args);
|
||||
} else if (window._runScripts === "dangerously") {
|
||||
vm.runInContext(handler, window, { filename: window.location.href, displayErrors: false });
|
||||
}
|
||||
} catch (e) {
|
||||
reportException(window, e, window.location.href);
|
||||
}
|
||||
|
||||
if (listOfActiveTimers.has(handle)) {
|
||||
if (repeat) {
|
||||
timerInitializationSteps(handler, timeout, args, { methodContext, repeat: true, previousHandle: handle });
|
||||
} else {
|
||||
listOfActiveTimers.delete(handle);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (timeout < 0) {
|
||||
timeout = 0;
|
||||
}
|
||||
|
||||
const nodejsTimer = setTimeout(task, timeout);
|
||||
listOfActiveTimers.set(handle, nodejsTimer);
|
||||
|
||||
return handle;
|
||||
}
|
||||
|
||||
this.__stopAllTimers = function () {
|
||||
stopAllTimers(timers);
|
||||
stopAllTimers(animationFrameCallbacks);
|
||||
// https://html.spec.whatwg.org/multipage/imagebitmap-and-animations.html#animation-frames
|
||||
|
||||
latestTimerId = 0;
|
||||
latestAnimationFrameCallbackId = 0;
|
||||
let animationFrameCallbackId = 0;
|
||||
const mapOfAnimationFrameCallbacks = new Map();
|
||||
let animationFrameNodejsInterval = null;
|
||||
|
||||
timers = Object.create(null);
|
||||
animationFrameCallbacks = Object.create(null);
|
||||
};
|
||||
// Unlike the spec, where an animation frame happens every 60 Hz regardless, we optimize so that if there are no
|
||||
// requestAnimationFrame() calls outstanding, we don't fire the timer. This helps us track that.
|
||||
let numberOfOngoingAnimationFrameCallbacks = 0;
|
||||
|
||||
if (this._pretendToBeVisual) {
|
||||
this.requestAnimationFrame = function (callback) {
|
||||
callback = webIDLConversions.Function(callback);
|
||||
|
||||
const handle = ++animationFrameCallbackId;
|
||||
mapOfAnimationFrameCallbacks.set(handle, callback);
|
||||
|
||||
++numberOfOngoingAnimationFrameCallbacks;
|
||||
if (numberOfOngoingAnimationFrameCallbacks === 1) {
|
||||
animationFrameNodejsInterval = setInterval(() => {
|
||||
runAnimationFrameCallbacks(rawPerformance.now() - windowInitialized);
|
||||
}, 1000 / 60);
|
||||
}
|
||||
|
||||
return handle;
|
||||
};
|
||||
|
||||
this.cancelAnimationFrame = function (handle) {
|
||||
handle = webIDLConversions["unsigned long"](handle);
|
||||
|
||||
removeAnimationFrameCallback(handle);
|
||||
};
|
||||
|
||||
function runAnimationFrameCallbacks(now) {
|
||||
// Converting to an array is important to get a sync snapshot and thus match spec semantics.
|
||||
const callbackHandles = [...mapOfAnimationFrameCallbacks.keys()];
|
||||
for (const handle of callbackHandles) {
|
||||
// This has() can be false if a callback calls cancelAnimationFrame().
|
||||
if (mapOfAnimationFrameCallbacks.has(handle)) {
|
||||
const callback = mapOfAnimationFrameCallbacks.get(handle);
|
||||
removeAnimationFrameCallback(handle);
|
||||
try {
|
||||
callback(now);
|
||||
} catch (e) {
|
||||
reportException(window, e, window.location.href);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function removeAnimationFrameCallback(handle) {
|
||||
if (mapOfAnimationFrameCallbacks.has(handle)) {
|
||||
--numberOfOngoingAnimationFrameCallbacks;
|
||||
if (numberOfOngoingAnimationFrameCallbacks === 0) {
|
||||
clearInterval(animationFrameNodejsInterval);
|
||||
}
|
||||
}
|
||||
|
||||
mapOfAnimationFrameCallbacks.delete(handle);
|
||||
}
|
||||
}
|
||||
|
||||
function stopAllTimers() {
|
||||
for (const nodejsTimer of listOfActiveTimers.values()) {
|
||||
clearTimeout(nodejsTimer);
|
||||
}
|
||||
listOfActiveTimers.clear();
|
||||
|
||||
clearInterval(animationFrameNodejsInterval);
|
||||
}
|
||||
|
||||
function Option(text, value, defaultSelected, selected) {
|
||||
if (text === undefined) {
|
||||
@@ -348,10 +506,10 @@ function Window(options) {
|
||||
impl.text = text;
|
||||
}
|
||||
if (value !== undefined) {
|
||||
impl.setAttribute("value", value);
|
||||
impl.setAttributeNS(null, "value", value);
|
||||
}
|
||||
if (defaultSelected) {
|
||||
impl.setAttribute("selected", "");
|
||||
impl.setAttributeNS(null, "selected", "");
|
||||
}
|
||||
impl._selectedness = selected;
|
||||
|
||||
@@ -375,10 +533,10 @@ function Window(options) {
|
||||
const impl = idlUtils.implForWrapper(img);
|
||||
|
||||
if (arguments.length > 0) {
|
||||
impl.setAttribute("width", String(arguments[0]));
|
||||
impl.setAttributeNS(null, "width", String(arguments[0]));
|
||||
}
|
||||
if (arguments.length > 1) {
|
||||
impl.setAttribute("height", String(arguments[1]));
|
||||
impl.setAttributeNS(null, "height", String(arguments[1]));
|
||||
}
|
||||
|
||||
return img;
|
||||
@@ -399,10 +557,10 @@ function Window(options) {
|
||||
function Audio(src) {
|
||||
const audio = window._document.createElement("audio");
|
||||
const impl = idlUtils.implForWrapper(audio);
|
||||
impl.setAttribute("preload", "auto");
|
||||
impl.setAttributeNS(null, "preload", "auto");
|
||||
|
||||
if (src !== undefined) {
|
||||
impl.setAttribute("src", String(src));
|
||||
impl.setAttributeNS(null, "src", String(src));
|
||||
}
|
||||
|
||||
return audio;
|
||||
@@ -420,18 +578,15 @@ function Window(options) {
|
||||
writable: true
|
||||
});
|
||||
|
||||
function wrapConsoleMethod(method) {
|
||||
return (...args) => {
|
||||
window._virtualConsole.emit(method, ...args);
|
||||
};
|
||||
}
|
||||
|
||||
this.postMessage = postMessage;
|
||||
this.postMessage = postMessage(window);
|
||||
|
||||
this.atob = function (str) {
|
||||
const result = atob(str);
|
||||
if (result === null) {
|
||||
throw new DOMException("The string to be decoded contains invalid characters.", "InvalidCharacterError");
|
||||
throw DOMException.create(window, [
|
||||
"The string to be decoded contains invalid characters.",
|
||||
"InvalidCharacterError"
|
||||
]);
|
||||
}
|
||||
return result;
|
||||
};
|
||||
@@ -439,40 +594,14 @@ function Window(options) {
|
||||
this.btoa = function (str) {
|
||||
const result = btoa(str);
|
||||
if (result === null) {
|
||||
throw new DOMException("The string to be encoded contains invalid characters.", "InvalidCharacterError");
|
||||
throw DOMException.create(window, [
|
||||
"The string to be encoded contains invalid characters.",
|
||||
"InvalidCharacterError"
|
||||
]);
|
||||
}
|
||||
return result;
|
||||
};
|
||||
|
||||
this.FileReader = createFileReader({
|
||||
window: this
|
||||
}).interface;
|
||||
this.WebSocket = createWebSocket({
|
||||
window: this
|
||||
}).interface;
|
||||
|
||||
const AbortSignalWrapper = createAbortSignal({
|
||||
window: this
|
||||
});
|
||||
this.AbortSignal = AbortSignalWrapper.interface;
|
||||
this.AbortController = createAbortController({
|
||||
AbortSignal: AbortSignalWrapper
|
||||
}).interface;
|
||||
|
||||
this.XMLHttpRequest = createXMLHttpRequest(this);
|
||||
|
||||
// TODO: necessary for Blob and FileReader due to different-globals weirdness; investigate how to avoid this.
|
||||
this.ArrayBuffer = ArrayBuffer;
|
||||
this.Int8Array = Int8Array;
|
||||
this.Uint8Array = Uint8Array;
|
||||
this.Uint8ClampedArray = Uint8ClampedArray;
|
||||
this.Int16Array = Int16Array;
|
||||
this.Uint16Array = Uint16Array;
|
||||
this.Int32Array = Int32Array;
|
||||
this.Uint32Array = Uint32Array;
|
||||
this.Float32Array = Float32Array;
|
||||
this.Float64Array = Float64Array;
|
||||
|
||||
this.stop = function () {
|
||||
const manager = idlUtils.implForWrapper(this._document)._requestManager;
|
||||
if (manager) {
|
||||
@@ -481,18 +610,10 @@ function Window(options) {
|
||||
};
|
||||
|
||||
this.close = function () {
|
||||
// Recursively close child frame windows, then ourselves.
|
||||
const currentWindow = this;
|
||||
(function windowCleaner(windowToClean) {
|
||||
for (let i = 0; i < windowToClean.length; i++) {
|
||||
windowCleaner(windowToClean[i]);
|
||||
}
|
||||
|
||||
// We"re already in our own window.close().
|
||||
if (windowToClean !== currentWindow) {
|
||||
windowToClean.close();
|
||||
}
|
||||
}(this));
|
||||
// Recursively close child frame windows, then ourselves (depth-first).
|
||||
for (let i = 0; i < this.length; ++i) {
|
||||
this[i].close();
|
||||
}
|
||||
|
||||
// Clear out all listeners. Any in-flight or upcoming events should not get delivered.
|
||||
idlUtils.implForWrapper(this)._eventListeners = Object.create(null);
|
||||
@@ -515,53 +636,56 @@ function Window(options) {
|
||||
delete this._document;
|
||||
}
|
||||
|
||||
this.__stopAllTimers();
|
||||
stopAllTimers();
|
||||
WebSocketImpl.cleanUpWindow(this);
|
||||
};
|
||||
|
||||
this.getComputedStyle = function (node) {
|
||||
const nodeImpl = idlUtils.implForWrapper(node);
|
||||
const s = node.style;
|
||||
const cs = new CSSStyleDeclaration();
|
||||
this.getComputedStyle = function (elt) {
|
||||
elt = Element.convert(elt);
|
||||
let pseudoElt = arguments[1];
|
||||
if (pseudoElt !== undefined && pseudoElt !== null) {
|
||||
pseudoElt = webIDLConversions.DOMString(pseudoElt);
|
||||
}
|
||||
|
||||
if (pseudoElt !== undefined && pseudoElt !== null && pseudoElt !== "") {
|
||||
// TODO: Parse pseudoElt
|
||||
|
||||
if (SHADOW_DOM_PSEUDO_REGEXP.test(pseudoElt)) {
|
||||
throw new TypeError("Tried to get the computed style of a Shadow DOM pseudo-element.");
|
||||
}
|
||||
|
||||
notImplemented("window.computedStyle(elt, pseudoElt)", this);
|
||||
}
|
||||
|
||||
const declaration = new CSSStyleDeclaration();
|
||||
const { forEach } = Array.prototype;
|
||||
const { style } = elt;
|
||||
|
||||
function setPropertiesFromRule(rule) {
|
||||
if (!rule.selectorText) {
|
||||
return;
|
||||
}
|
||||
|
||||
const selectors = rule.selectorText.split(cssSelectorSplitRE);
|
||||
let matched = false;
|
||||
for (const selectorText of selectors) {
|
||||
if (selectorText !== "" && selectorText !== "," && !matched && matchesDontThrow(nodeImpl, selectorText)) {
|
||||
matched = true;
|
||||
forEach.call(rule.style, property => {
|
||||
cs.setProperty(property, rule.style.getPropertyValue(property), rule.style.getPropertyPriority(property));
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function readStylesFromStyleSheet(sheet) {
|
||||
forEach.call(sheet.cssRules, rule => {
|
||||
if (rule.media) {
|
||||
if (Array.prototype.indexOf.call(rule.media, "screen") !== -1) {
|
||||
forEach.call(rule.cssRules, setPropertiesFromRule);
|
||||
}
|
||||
} else {
|
||||
setPropertiesFromRule(rule);
|
||||
}
|
||||
forEachMatchingSheetRuleOfElement(elt, rule => {
|
||||
forEach.call(rule.style, property => {
|
||||
declaration.setProperty(
|
||||
property,
|
||||
rule.style.getPropertyValue(property),
|
||||
rule.style.getPropertyPriority(property)
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
readStylesFromStyleSheet(defaultStyleSheet);
|
||||
forEach.call(node.ownerDocument.styleSheets, readStylesFromStyleSheet);
|
||||
|
||||
forEach.call(s, property => {
|
||||
cs.setProperty(property, s.getPropertyValue(property), s.getPropertyPriority(property));
|
||||
});
|
||||
|
||||
return cs;
|
||||
// https://drafts.csswg.org/cssom/#dom-window-getcomputedstyle
|
||||
const declarations = Object.keys(propertiesWithResolvedValueImplemented);
|
||||
forEach.call(declarations, property => {
|
||||
declaration.setProperty(property, getResolvedValue(elt, property));
|
||||
});
|
||||
|
||||
forEach.call(style, property => {
|
||||
declaration.setProperty(property, style.getPropertyValue(property), style.getPropertyPriority(property));
|
||||
});
|
||||
|
||||
return declaration;
|
||||
};
|
||||
|
||||
this.getSelection = function () {
|
||||
return window._document.getSelection();
|
||||
};
|
||||
|
||||
// The captureEvents() and releaseEvents() methods must do nothing
|
||||
@@ -571,11 +695,20 @@ function Window(options) {
|
||||
|
||||
///// PUBLIC DATA PROPERTIES (TODO: should be getters)
|
||||
|
||||
function wrapConsoleMethod(method) {
|
||||
return (...args) => {
|
||||
window._virtualConsole.emit(method, ...args);
|
||||
};
|
||||
}
|
||||
|
||||
this.console = {
|
||||
assert: wrapConsoleMethod("assert"),
|
||||
clear: wrapConsoleMethod("clear"),
|
||||
count: wrapConsoleMethod("count"),
|
||||
countReset: wrapConsoleMethod("countReset"),
|
||||
debug: wrapConsoleMethod("debug"),
|
||||
dir: wrapConsoleMethod("dir"),
|
||||
dirxml: wrapConsoleMethod("dirxml"),
|
||||
error: wrapConsoleMethod("error"),
|
||||
group: wrapConsoleMethod("group"),
|
||||
groupCollapsed: wrapConsoleMethod("groupCollapsed"),
|
||||
@@ -584,6 +717,7 @@ function Window(options) {
|
||||
log: wrapConsoleMethod("log"),
|
||||
table: wrapConsoleMethod("table"),
|
||||
time: wrapConsoleMethod("time"),
|
||||
timeLog: wrapConsoleMethod("timeLog"),
|
||||
timeEnd: wrapConsoleMethod("timeEnd"),
|
||||
trace: wrapConsoleMethod("trace"),
|
||||
warn: wrapConsoleMethod("warn")
|
||||
@@ -596,10 +730,8 @@ function Window(options) {
|
||||
}
|
||||
|
||||
define(this, {
|
||||
name: "nodejs",
|
||||
// Node v6 has issues (presumably in the vm module)
|
||||
// which this property exposes through an XHR test
|
||||
// status: "",
|
||||
name: "",
|
||||
status: "",
|
||||
devicePixelRatio: 1,
|
||||
innerWidth: 1024,
|
||||
innerHeight: 768,
|
||||
@@ -608,15 +740,12 @@ function Window(options) {
|
||||
pageXOffset: 0,
|
||||
pageYOffset: 0,
|
||||
screenX: 0,
|
||||
screenLeft: 0,
|
||||
screenY: 0,
|
||||
screenTop: 0,
|
||||
scrollX: 0,
|
||||
scrollY: 0,
|
||||
|
||||
// Not in spec, but likely to be added eventually:
|
||||
// https://github.com/w3c/csswg-drafts/issues/1091
|
||||
screenLeft: 0,
|
||||
screenTop: 0,
|
||||
|
||||
alert: notImplementedMethod("window.alert"),
|
||||
blur: notImplementedMethod("window.blur"),
|
||||
confirm: notImplementedMethod("window.confirm"),
|
||||
@@ -641,64 +770,24 @@ function Window(options) {
|
||||
}
|
||||
|
||||
if (window.document.readyState === "complete") {
|
||||
const ev = window.document.createEvent("HTMLEvents");
|
||||
ev.initEvent("load", false, false);
|
||||
window.dispatchEvent(ev);
|
||||
fireAnEvent("load", window, undefined, {}, window.document);
|
||||
} else {
|
||||
window.document.addEventListener("load", () => {
|
||||
const ev = window.document.createEvent("HTMLEvents");
|
||||
ev.initEvent("load", false, false);
|
||||
window.dispatchEvent(ev);
|
||||
fireAnEvent("load", window, undefined, {}, window.document);
|
||||
|
||||
if (!idlUtils.implForWrapper(window._document)._pageShowingFlag) {
|
||||
idlUtils.implForWrapper(window._document)._pageShowingFlag = true;
|
||||
fireAnEvent("pageshow", window, PageTransitionEvent, { persisted: false }, window.document);
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
Object.setPrototypeOf(Window, EventTarget.interface);
|
||||
Object.setPrototypeOf(Window.prototype, EventTarget.interface.prototype);
|
||||
Object.defineProperty(Window.prototype, Symbol.toStringTag, {
|
||||
value: "Window",
|
||||
writable: false,
|
||||
enumerable: false,
|
||||
configurable: true
|
||||
});
|
||||
|
||||
function startTimer(window, startFn, stopFn, timerId, callback, ms, timerStorage, args) {
|
||||
if (!window || !window._document) {
|
||||
return undefined;
|
||||
}
|
||||
if (typeof callback !== "function") {
|
||||
const code = String(callback);
|
||||
callback = window._globalProxy.eval.bind(window, code + `\n//# sourceURL=${window.location.href}`);
|
||||
function contextifyWindow(window) {
|
||||
if (vm.isContext(window)) {
|
||||
return;
|
||||
}
|
||||
|
||||
const oldCallback = callback;
|
||||
callback = () => {
|
||||
try {
|
||||
oldCallback.apply(window._globalProxy, args);
|
||||
} catch (e) {
|
||||
reportException(window, e, window.location.href);
|
||||
}
|
||||
};
|
||||
|
||||
const res = startFn(callback, ms);
|
||||
timerStorage[timerId] = [res, stopFn];
|
||||
return timerId;
|
||||
}
|
||||
|
||||
function stopTimer(timerStorage, id) {
|
||||
const timer = timerStorage[id];
|
||||
if (timer) {
|
||||
// Need to .call() with undefined to ensure the thisArg is not timer itself
|
||||
timer[1].call(undefined, timer[0]);
|
||||
delete timerStorage[id];
|
||||
}
|
||||
}
|
||||
|
||||
function stopAllTimers(timers) {
|
||||
Object.keys(timers).forEach(key => {
|
||||
const timer = timers[key];
|
||||
// Need to .call() with undefined to ensure the thisArg is not timer itself
|
||||
timer[1].call(undefined, timer[0]);
|
||||
});
|
||||
vm.createContext(window);
|
||||
}
|
||||
|
||||
55
node_modules/jsdom/lib/jsdom/browser/documentfeatures.js
generated
vendored
55
node_modules/jsdom/lib/jsdom/browser/documentfeatures.js
generated
vendored
@@ -1,55 +0,0 @@
|
||||
"use strict";
|
||||
const vm = require("vm");
|
||||
const idlUtils = require("../living/generated/utils");
|
||||
|
||||
exports.availableDocumentFeatures = [
|
||||
"FetchExternalResources",
|
||||
"SkipExternalResources"
|
||||
];
|
||||
|
||||
exports.defaultDocumentFeatures = {
|
||||
FetchExternalResources: ["script", "link"], // omitted by default: "frame"
|
||||
SkipExternalResources: false
|
||||
};
|
||||
|
||||
exports.applyDocumentFeatures = (documentImpl, features = {}) => {
|
||||
for (let i = 0; i < exports.availableDocumentFeatures.length; ++i) {
|
||||
const featureName = exports.availableDocumentFeatures[i];
|
||||
let featureSource;
|
||||
|
||||
if (features[featureName] !== undefined) {
|
||||
featureSource = features[featureName];
|
||||
// We have to check the lowercase version also because the Document feature
|
||||
// methods convert everything to lowercase.
|
||||
} else if (typeof features[featureName.toLowerCase()] !== "undefined") {
|
||||
featureSource = features[featureName.toLowerCase()];
|
||||
} else if (exports.defaultDocumentFeatures[featureName]) {
|
||||
featureSource = exports.defaultDocumentFeatures[featureName];
|
||||
} else {
|
||||
continue;
|
||||
}
|
||||
|
||||
const implImpl = documentImpl._implementation;
|
||||
implImpl._removeFeature(featureName);
|
||||
|
||||
if (featureSource !== undefined) {
|
||||
if (Array.isArray(featureSource)) {
|
||||
for (let j = 0; j < featureSource.length; ++j) {
|
||||
implImpl._addFeature(featureName, featureSource[j]);
|
||||
}
|
||||
} else {
|
||||
implImpl._addFeature(featureName, featureSource);
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
exports.contextifyWindow = window => {
|
||||
if (vm.isContext(window)) {
|
||||
return;
|
||||
}
|
||||
|
||||
vm.createContext(window);
|
||||
const documentImpl = idlUtils.implForWrapper(window._document);
|
||||
documentImpl._defaultView = window._globalProxy = vm.runInContext("this", window);
|
||||
};
|
||||
18
node_modules/jsdom/lib/jsdom/browser/domtohtml.js
generated
vendored
18
node_modules/jsdom/lib/jsdom/browser/domtohtml.js
generated
vendored
@@ -1,18 +0,0 @@
|
||||
"use strict";
|
||||
const parse5 = require("parse5");
|
||||
const treeAdapter = require("./parse5-adapter-serialization");
|
||||
const NODE_TYPE = require("../living/node-type");
|
||||
|
||||
exports.domToHtml = iterable => {
|
||||
let ret = "";
|
||||
for (const node of iterable) {
|
||||
if (node.nodeType === NODE_TYPE.DOCUMENT_NODE) {
|
||||
ret += parse5.serialize(node, { treeAdapter });
|
||||
} else {
|
||||
// TODO: maybe parse5 can give us a hook where it serializes the node itself too:
|
||||
// https://github.com/inikulin/parse5/issues/230
|
||||
ret += parse5.serialize({ childNodesForSerializing: [node] }, { treeAdapter });
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
};
|
||||
271
node_modules/jsdom/lib/jsdom/browser/htmltodom.js
generated
vendored
271
node_modules/jsdom/lib/jsdom/browser/htmltodom.js
generated
vendored
@@ -1,271 +0,0 @@
|
||||
"use strict";
|
||||
|
||||
const parse5 = require("parse5");
|
||||
const sax = require("sax");
|
||||
const attributes = require("../living/attributes");
|
||||
const DocumentType = require("../living/generated/DocumentType");
|
||||
const JSDOMParse5Adapter = require("./parse5-adapter-parsing");
|
||||
const { HTML_NS } = require("../living/helpers/namespaces");
|
||||
|
||||
// Horrible monkey-patch to implement https://github.com/inikulin/parse5/issues/237
|
||||
const OpenElementStack = require("parse5/lib/parser/open_element_stack");
|
||||
const originalPop = OpenElementStack.prototype.pop;
|
||||
OpenElementStack.prototype.pop = function (...args) {
|
||||
const before = this.items[this.stackTop];
|
||||
originalPop.apply(this, args);
|
||||
if (before._poppedOffStackOfOpenElements) {
|
||||
before._poppedOffStackOfOpenElements();
|
||||
}
|
||||
};
|
||||
|
||||
const originalPush = OpenElementStack.prototype.push;
|
||||
OpenElementStack.prototype.push = function (...args) {
|
||||
originalPush.apply(this, args);
|
||||
const after = this.items[this.stackTop];
|
||||
if (after._pushedOnStackOfOpenElements) {
|
||||
after._pushedOnStackOfOpenElements();
|
||||
}
|
||||
};
|
||||
|
||||
module.exports = class HTMLToDOM {
|
||||
constructor(parsingMode) {
|
||||
this.parser = parsingMode === "xml" ? sax : parse5;
|
||||
}
|
||||
|
||||
appendToNode(html, node) {
|
||||
html = String(html);
|
||||
|
||||
return this._doParse(html, true, node);
|
||||
}
|
||||
|
||||
appendToDocument(html, documentImpl) {
|
||||
html = String(html);
|
||||
|
||||
return this._doParse(html, false, documentImpl, documentImpl._parseOptions);
|
||||
}
|
||||
|
||||
_doParse(...args) {
|
||||
return this.parser === parse5 ? this._parseWithParse5(...args) : this._parseWithSax(...args);
|
||||
}
|
||||
|
||||
_parseWithParse5(html, isFragment, contextNode, options = {}) {
|
||||
const adapter = new JSDOMParse5Adapter(contextNode._ownerDocument || contextNode);
|
||||
options.treeAdapter = adapter;
|
||||
|
||||
if (isFragment) {
|
||||
const fragment = this.parser.parseFragment(contextNode, html, options);
|
||||
|
||||
if (contextNode._templateContents) {
|
||||
contextNode._templateContents.appendChild(fragment);
|
||||
} else {
|
||||
contextNode.appendChild(fragment);
|
||||
}
|
||||
} else {
|
||||
this.parser.parse(html, options);
|
||||
}
|
||||
|
||||
return contextNode;
|
||||
}
|
||||
|
||||
_parseWithSax(html, isFragment, contextNode) {
|
||||
const SaxParser = this.parser.parser;
|
||||
const parser = new SaxParser(/* strict = */true, { xmlns: true, strictEntities: true });
|
||||
parser.noscript = false;
|
||||
parser.looseCase = "toString";
|
||||
const openStack = [contextNode];
|
||||
parser.ontext = text => {
|
||||
setChildForSax(openStack[openStack.length - 1], {
|
||||
type: "text",
|
||||
data: text
|
||||
});
|
||||
};
|
||||
parser.oncdata = cdata => {
|
||||
setChildForSax(openStack[openStack.length - 1], {
|
||||
type: "cdata",
|
||||
data: cdata
|
||||
});
|
||||
};
|
||||
parser.onopentag = arg => {
|
||||
const attrs = Object.keys(arg.attributes).map(key => {
|
||||
const rawAttribute = arg.attributes[key];
|
||||
|
||||
let { prefix } = rawAttribute;
|
||||
let localName = rawAttribute.local;
|
||||
if (prefix === "xmlns" && localName === "") {
|
||||
// intended weirdness in node-sax, see https://github.com/isaacs/sax-js/issues/165
|
||||
localName = prefix;
|
||||
prefix = null;
|
||||
}
|
||||
|
||||
if (prefix === "") {
|
||||
prefix = null;
|
||||
}
|
||||
|
||||
const namespace = rawAttribute.uri === "" ? null : rawAttribute.uri;
|
||||
|
||||
return { name: rawAttribute.name, value: rawAttribute.value, prefix, localName, namespace };
|
||||
});
|
||||
const tag = {
|
||||
type: "tag",
|
||||
name: arg.local,
|
||||
prefix: arg.prefix,
|
||||
namespace: arg.uri,
|
||||
attributes: attrs
|
||||
};
|
||||
|
||||
if (arg.local === "script" && arg.uri === HTML_NS) {
|
||||
openStack.push(tag);
|
||||
} else {
|
||||
const elem = setChildForSax(openStack[openStack.length - 1], tag);
|
||||
openStack.push(elem);
|
||||
}
|
||||
};
|
||||
parser.onclosetag = () => {
|
||||
const elem = openStack.pop();
|
||||
if (elem.constructor.name === "Object") { // we have an empty script tag
|
||||
setChildForSax(openStack[openStack.length - 1], elem);
|
||||
}
|
||||
};
|
||||
parser.onscript = scriptText => {
|
||||
const tag = openStack.pop();
|
||||
tag.children = [{ type: "text", data: scriptText }];
|
||||
const elem = setChildForSax(openStack[openStack.length - 1], tag);
|
||||
openStack.push(elem);
|
||||
};
|
||||
parser.oncomment = comment => {
|
||||
setChildForSax(openStack[openStack.length - 1], {
|
||||
type: "comment",
|
||||
data: comment
|
||||
});
|
||||
};
|
||||
parser.onprocessinginstruction = pi => {
|
||||
setChildForSax(openStack[openStack.length - 1], {
|
||||
type: "directive",
|
||||
name: "?" + pi.name,
|
||||
data: "?" + pi.name + " " + pi.body + "?"
|
||||
});
|
||||
};
|
||||
parser.ondoctype = dt => {
|
||||
setChildForSax(openStack[openStack.length - 1], {
|
||||
type: "directive",
|
||||
name: "!doctype",
|
||||
data: "!doctype " + dt
|
||||
});
|
||||
|
||||
const entityMatcher = /<!ENTITY ([^ ]+) "([^"]+)">/g;
|
||||
let result;
|
||||
while ((result = entityMatcher.exec(dt))) {
|
||||
const [, name, value] = result;
|
||||
if (!(name in parser.ENTITIES)) {
|
||||
parser.ENTITIES[name] = value;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
parser.onerror = err => {
|
||||
throw err;
|
||||
};
|
||||
parser.write(html).close();
|
||||
}
|
||||
};
|
||||
|
||||
function setChildForSax(parentImpl, node) {
|
||||
const currentDocument = (parentImpl && parentImpl._ownerDocument) || parentImpl;
|
||||
|
||||
let newNode;
|
||||
let isTemplateContents = false;
|
||||
switch (node.type) {
|
||||
case "tag":
|
||||
case "script":
|
||||
case "style":
|
||||
newNode = currentDocument._createElementWithCorrectElementInterface(node.name, node.namespace);
|
||||
newNode._prefix = node.prefix || null;
|
||||
newNode._namespaceURI = node.namespace || null;
|
||||
break;
|
||||
|
||||
case "root":
|
||||
// If we are in <template> then add all children to the parent's _templateContents; skip this virtual root node.
|
||||
if (parentImpl.tagName === "TEMPLATE" && parentImpl._namespaceURI === HTML_NS) {
|
||||
newNode = parentImpl._templateContents;
|
||||
isTemplateContents = true;
|
||||
}
|
||||
break;
|
||||
|
||||
case "text":
|
||||
// HTML entities should already be decoded by the parser, so no need to decode them
|
||||
newNode = currentDocument.createTextNode(node.data);
|
||||
break;
|
||||
|
||||
case "cdata":
|
||||
newNode = currentDocument.createCDATASection(node.data);
|
||||
break;
|
||||
|
||||
case "comment":
|
||||
newNode = currentDocument.createComment(node.data);
|
||||
break;
|
||||
|
||||
case "directive":
|
||||
if (node.name[0] === "?" && node.name.toLowerCase() !== "?xml") {
|
||||
const data = node.data.slice(node.name.length + 1, -1);
|
||||
newNode = currentDocument.createProcessingInstruction(node.name.substring(1), data);
|
||||
} else if (node.name.toLowerCase() === "!doctype") {
|
||||
newNode = parseDocType(currentDocument, "<" + node.data + ">");
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
if (!newNode) {
|
||||
return null;
|
||||
}
|
||||
|
||||
if (node.attributes) {
|
||||
for (const a of node.attributes) {
|
||||
attributes.setAttributeValue(newNode, a.localName, a.value, a.prefix, a.namespace);
|
||||
}
|
||||
}
|
||||
|
||||
if (node.children) {
|
||||
for (let c = 0; c < node.children.length; c++) {
|
||||
setChildForSax(newNode, node.children[c]);
|
||||
}
|
||||
}
|
||||
|
||||
if (!isTemplateContents) {
|
||||
if (parentImpl._templateContents) {
|
||||
// Setting innerHTML on a <template>
|
||||
parentImpl._templateContents.appendChild(newNode);
|
||||
} else {
|
||||
parentImpl.appendChild(newNode);
|
||||
}
|
||||
}
|
||||
|
||||
return newNode;
|
||||
}
|
||||
|
||||
const HTML5_DOCTYPE = /<!doctype html>/i;
|
||||
const PUBLIC_DOCTYPE = /<!doctype\s+([^\s]+)\s+public\s+"([^"]+)"\s+"([^"]+)"/i;
|
||||
const SYSTEM_DOCTYPE = /<!doctype\s+([^\s]+)\s+system\s+"([^"]+)"/i;
|
||||
|
||||
function parseDocType(doc, html) {
|
||||
if (HTML5_DOCTYPE.test(html)) {
|
||||
return createDocumentTypeInternal(doc, "html", "", "");
|
||||
}
|
||||
|
||||
const publicPieces = PUBLIC_DOCTYPE.exec(html);
|
||||
if (publicPieces) {
|
||||
return createDocumentTypeInternal(doc, publicPieces[1], publicPieces[2], publicPieces[3]);
|
||||
}
|
||||
|
||||
const systemPieces = SYSTEM_DOCTYPE.exec(html);
|
||||
if (systemPieces) {
|
||||
return createDocumentTypeInternal(doc, systemPieces[1], "", systemPieces[2]);
|
||||
}
|
||||
|
||||
// Shouldn't get here (the parser shouldn't let us know about invalid doctypes), but our logic likely isn't
|
||||
// real-world perfect, so let's fallback.
|
||||
return createDocumentTypeInternal(doc, "html", "", "");
|
||||
}
|
||||
|
||||
function createDocumentTypeInternal(ownerDocument, name, publicId, systemId) {
|
||||
return DocumentType.createImpl([], { ownerDocument, name, publicId, systemId });
|
||||
}
|
||||
292
node_modules/jsdom/lib/jsdom/browser/js-globals.json
generated
vendored
Normal file
292
node_modules/jsdom/lib/jsdom/browser/js-globals.json
generated
vendored
Normal file
@@ -0,0 +1,292 @@
|
||||
{
|
||||
"Object": {
|
||||
"writable": true,
|
||||
"enumerable": false,
|
||||
"configurable": true
|
||||
},
|
||||
"Function": {
|
||||
"writable": true,
|
||||
"enumerable": false,
|
||||
"configurable": true
|
||||
},
|
||||
"Array": {
|
||||
"writable": true,
|
||||
"enumerable": false,
|
||||
"configurable": true
|
||||
},
|
||||
"Number": {
|
||||
"writable": true,
|
||||
"enumerable": false,
|
||||
"configurable": true
|
||||
},
|
||||
"parseFloat": {
|
||||
"writable": true,
|
||||
"enumerable": false,
|
||||
"configurable": true
|
||||
},
|
||||
"parseInt": {
|
||||
"writable": true,
|
||||
"enumerable": false,
|
||||
"configurable": true
|
||||
},
|
||||
"Infinity": {
|
||||
"writable": false,
|
||||
"enumerable": false,
|
||||
"configurable": false
|
||||
},
|
||||
"NaN": {
|
||||
"writable": false,
|
||||
"enumerable": false,
|
||||
"configurable": false
|
||||
},
|
||||
"undefined": {
|
||||
"writable": false,
|
||||
"enumerable": false,
|
||||
"configurable": false
|
||||
},
|
||||
"Boolean": {
|
||||
"writable": true,
|
||||
"enumerable": false,
|
||||
"configurable": true
|
||||
},
|
||||
"String": {
|
||||
"writable": true,
|
||||
"enumerable": false,
|
||||
"configurable": true
|
||||
},
|
||||
"Symbol": {
|
||||
"writable": true,
|
||||
"enumerable": false,
|
||||
"configurable": true
|
||||
},
|
||||
"Date": {
|
||||
"writable": true,
|
||||
"enumerable": false,
|
||||
"configurable": true
|
||||
},
|
||||
"Promise": {
|
||||
"writable": true,
|
||||
"enumerable": false,
|
||||
"configurable": true
|
||||
},
|
||||
"RegExp": {
|
||||
"writable": true,
|
||||
"enumerable": false,
|
||||
"configurable": true
|
||||
},
|
||||
"Error": {
|
||||
"writable": true,
|
||||
"enumerable": false,
|
||||
"configurable": true
|
||||
},
|
||||
"EvalError": {
|
||||
"writable": true,
|
||||
"enumerable": false,
|
||||
"configurable": true
|
||||
},
|
||||
"RangeError": {
|
||||
"writable": true,
|
||||
"enumerable": false,
|
||||
"configurable": true
|
||||
},
|
||||
"ReferenceError": {
|
||||
"writable": true,
|
||||
"enumerable": false,
|
||||
"configurable": true
|
||||
},
|
||||
"SyntaxError": {
|
||||
"writable": true,
|
||||
"enumerable": false,
|
||||
"configurable": true
|
||||
},
|
||||
"TypeError": {
|
||||
"writable": true,
|
||||
"enumerable": false,
|
||||
"configurable": true
|
||||
},
|
||||
"URIError": {
|
||||
"writable": true,
|
||||
"enumerable": false,
|
||||
"configurable": true
|
||||
},
|
||||
"globalThis": {
|
||||
"writable": true,
|
||||
"enumerable": false,
|
||||
"configurable": true
|
||||
},
|
||||
"JSON": {
|
||||
"writable": true,
|
||||
"enumerable": false,
|
||||
"configurable": true
|
||||
},
|
||||
"Math": {
|
||||
"writable": true,
|
||||
"enumerable": false,
|
||||
"configurable": true
|
||||
},
|
||||
"Intl": {
|
||||
"writable": true,
|
||||
"enumerable": false,
|
||||
"configurable": true
|
||||
},
|
||||
"ArrayBuffer": {
|
||||
"writable": true,
|
||||
"enumerable": false,
|
||||
"configurable": true
|
||||
},
|
||||
"Uint8Array": {
|
||||
"writable": true,
|
||||
"enumerable": false,
|
||||
"configurable": true
|
||||
},
|
||||
"Int8Array": {
|
||||
"writable": true,
|
||||
"enumerable": false,
|
||||
"configurable": true
|
||||
},
|
||||
"Uint16Array": {
|
||||
"writable": true,
|
||||
"enumerable": false,
|
||||
"configurable": true
|
||||
},
|
||||
"Int16Array": {
|
||||
"writable": true,
|
||||
"enumerable": false,
|
||||
"configurable": true
|
||||
},
|
||||
"Uint32Array": {
|
||||
"writable": true,
|
||||
"enumerable": false,
|
||||
"configurable": true
|
||||
},
|
||||
"Int32Array": {
|
||||
"writable": true,
|
||||
"enumerable": false,
|
||||
"configurable": true
|
||||
},
|
||||
"Float32Array": {
|
||||
"writable": true,
|
||||
"enumerable": false,
|
||||
"configurable": true
|
||||
},
|
||||
"Float64Array": {
|
||||
"writable": true,
|
||||
"enumerable": false,
|
||||
"configurable": true
|
||||
},
|
||||
"Uint8ClampedArray": {
|
||||
"writable": true,
|
||||
"enumerable": false,
|
||||
"configurable": true
|
||||
},
|
||||
"BigUint64Array": {
|
||||
"writable": true,
|
||||
"enumerable": false,
|
||||
"configurable": true
|
||||
},
|
||||
"BigInt64Array": {
|
||||
"writable": true,
|
||||
"enumerable": false,
|
||||
"configurable": true
|
||||
},
|
||||
"DataView": {
|
||||
"writable": true,
|
||||
"enumerable": false,
|
||||
"configurable": true
|
||||
},
|
||||
"Map": {
|
||||
"writable": true,
|
||||
"enumerable": false,
|
||||
"configurable": true
|
||||
},
|
||||
"BigInt": {
|
||||
"writable": true,
|
||||
"enumerable": false,
|
||||
"configurable": true
|
||||
},
|
||||
"Set": {
|
||||
"writable": true,
|
||||
"enumerable": false,
|
||||
"configurable": true
|
||||
},
|
||||
"WeakMap": {
|
||||
"writable": true,
|
||||
"enumerable": false,
|
||||
"configurable": true
|
||||
},
|
||||
"WeakSet": {
|
||||
"writable": true,
|
||||
"enumerable": false,
|
||||
"configurable": true
|
||||
},
|
||||
"Proxy": {
|
||||
"writable": true,
|
||||
"enumerable": false,
|
||||
"configurable": true
|
||||
},
|
||||
"Reflect": {
|
||||
"writable": true,
|
||||
"enumerable": false,
|
||||
"configurable": true
|
||||
},
|
||||
"decodeURI": {
|
||||
"writable": true,
|
||||
"enumerable": false,
|
||||
"configurable": true
|
||||
},
|
||||
"decodeURIComponent": {
|
||||
"writable": true,
|
||||
"enumerable": false,
|
||||
"configurable": true
|
||||
},
|
||||
"encodeURI": {
|
||||
"writable": true,
|
||||
"enumerable": false,
|
||||
"configurable": true
|
||||
},
|
||||
"encodeURIComponent": {
|
||||
"writable": true,
|
||||
"enumerable": false,
|
||||
"configurable": true
|
||||
},
|
||||
"escape": {
|
||||
"writable": true,
|
||||
"enumerable": false,
|
||||
"configurable": true
|
||||
},
|
||||
"unescape": {
|
||||
"writable": true,
|
||||
"enumerable": false,
|
||||
"configurable": true
|
||||
},
|
||||
"eval": {
|
||||
"writable": true,
|
||||
"enumerable": false,
|
||||
"configurable": true
|
||||
},
|
||||
"isFinite": {
|
||||
"writable": true,
|
||||
"enumerable": false,
|
||||
"configurable": true
|
||||
},
|
||||
"isNaN": {
|
||||
"writable": true,
|
||||
"enumerable": false,
|
||||
"configurable": true
|
||||
},
|
||||
"SharedArrayBuffer": {
|
||||
"writable": true,
|
||||
"enumerable": false,
|
||||
"configurable": true
|
||||
},
|
||||
"Atomics": {
|
||||
"writable": true,
|
||||
"enumerable": false,
|
||||
"configurable": true
|
||||
},
|
||||
"WebAssembly": {
|
||||
"writable": true,
|
||||
"enumerable": false,
|
||||
"configurable": true
|
||||
}
|
||||
}
|
||||
110
node_modules/jsdom/lib/jsdom/browser/parse5-adapter-parsing.js
generated
vendored
110
node_modules/jsdom/lib/jsdom/browser/parse5-adapter-parsing.js
generated
vendored
@@ -1,110 +0,0 @@
|
||||
"use strict";
|
||||
const DocumentType = require("../living/generated/DocumentType");
|
||||
const DocumentFragment = require("../living/generated/DocumentFragment");
|
||||
const Text = require("../living/generated/Text");
|
||||
const Comment = require("../living/generated/Comment");
|
||||
const attributes = require("../living/attributes");
|
||||
const nodeTypes = require("../living/node-type");
|
||||
const serializationAdapter = require("./parse5-adapter-serialization");
|
||||
|
||||
module.exports = class JSDOMParse5Adapter {
|
||||
constructor(documentImpl) {
|
||||
this._documentImpl = documentImpl;
|
||||
}
|
||||
|
||||
createDocument() {
|
||||
// parse5's model assumes that parse(html) will call into here to create the new Document, then return it. However,
|
||||
// jsdom's model assumes we can create a Window (and through that create an empty Document), do some other setup
|
||||
// stuff, and then parse, stuffing nodes into that Document as we go. So to adapt between these two models, we just
|
||||
// return the already-created Document when asked by parse5 to "create" a Document.
|
||||
return this._documentImpl;
|
||||
}
|
||||
|
||||
createDocumentFragment() {
|
||||
return DocumentFragment.createImpl([], { ownerDocument: this._documentImpl });
|
||||
}
|
||||
|
||||
createElement(localName, namespace, attrs) {
|
||||
const element = this._documentImpl._createElementWithCorrectElementInterface(localName, namespace);
|
||||
element._namespaceURI = namespace;
|
||||
this.adoptAttributes(element, attrs);
|
||||
|
||||
if ("_parserInserted" in element) {
|
||||
element._parserInserted = true;
|
||||
}
|
||||
|
||||
return element;
|
||||
}
|
||||
|
||||
createCommentNode(data) {
|
||||
return Comment.createImpl([], { data, ownerDocument: this._documentImpl });
|
||||
}
|
||||
|
||||
appendChild(parentNode, newNode) {
|
||||
parentNode.appendChild(newNode);
|
||||
}
|
||||
|
||||
insertBefore(parentNode, newNode, referenceNode) {
|
||||
parentNode.insertBefore(newNode, referenceNode);
|
||||
}
|
||||
|
||||
setTemplateContent(templateElement, contentFragment) {
|
||||
templateElement._templateContents = contentFragment;
|
||||
}
|
||||
|
||||
setDocumentType(document, name, publicId, systemId) {
|
||||
// parse5 sometimes gives us these as null.
|
||||
if (name === null) {
|
||||
name = "";
|
||||
}
|
||||
if (publicId === null) {
|
||||
publicId = "";
|
||||
}
|
||||
if (systemId === null) {
|
||||
systemId = "";
|
||||
}
|
||||
|
||||
const documentType = DocumentType.createImpl([], { name, publicId, systemId, ownerDocument: this._documentImpl });
|
||||
document.appendChild(documentType);
|
||||
}
|
||||
|
||||
setDocumentMode(document, mode) {
|
||||
// TODO: the rest of jsdom ignores this
|
||||
document._mode = mode;
|
||||
}
|
||||
|
||||
detachNode(node) {
|
||||
node.remove();
|
||||
}
|
||||
|
||||
insertText(parentNode, text) {
|
||||
const { lastChild } = parentNode;
|
||||
if (lastChild && lastChild.nodeType === nodeTypes.TEXT_NODE) {
|
||||
lastChild.data += text;
|
||||
} else {
|
||||
const textNode = Text.createImpl([], { data: text, ownerDocument: this._documentImpl });
|
||||
|
||||
parentNode.appendChild(textNode);
|
||||
}
|
||||
}
|
||||
|
||||
insertTextBefore(parentNode, text, referenceNode) {
|
||||
const { previousSibling } = referenceNode;
|
||||
if (previousSibling && previousSibling.nodeType === nodeTypes.TEXT_NODE) {
|
||||
previousSibling.data += text;
|
||||
} else {
|
||||
const textNode = Text.createImpl([], { data: text, ownerDocument: this._documentImpl });
|
||||
|
||||
parentNode.insertBefore(textNode, referenceNode);
|
||||
}
|
||||
}
|
||||
|
||||
adoptAttributes(element, attrs) {
|
||||
for (const attr of attrs) {
|
||||
const prefix = attr.prefix === "" ? null : attr.prefix;
|
||||
attributes.setAttributeValue(element, attr.name, attr.value, prefix, attr.namespace);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
Object.assign(module.exports.prototype, serializationAdapter);
|
||||
222
node_modules/jsdom/lib/jsdom/browser/parser/html.js
generated
vendored
Normal file
222
node_modules/jsdom/lib/jsdom/browser/parser/html.js
generated
vendored
Normal file
@@ -0,0 +1,222 @@
|
||||
"use strict";
|
||||
|
||||
const parse5 = require("parse5");
|
||||
|
||||
const { createElement } = require("../../living/helpers/create-element");
|
||||
|
||||
const DocumentType = require("../../living/generated/DocumentType");
|
||||
const DocumentFragment = require("../../living/generated/DocumentFragment");
|
||||
const Text = require("../../living/generated/Text");
|
||||
const Comment = require("../../living/generated/Comment");
|
||||
|
||||
const attributes = require("../../living/attributes");
|
||||
const nodeTypes = require("../../living/node-type");
|
||||
|
||||
const serializationAdapter = require("../../living/domparsing/parse5-adapter-serialization");
|
||||
const {
|
||||
customElementReactionsStack, invokeCEReactions, lookupCEDefinition
|
||||
} = require("../../living/helpers/custom-elements");
|
||||
|
||||
// Horrible monkey-patch to implement https://github.com/inikulin/parse5/issues/237 and
|
||||
// https://github.com/inikulin/parse5/issues/285.
|
||||
const OpenElementStack = require("parse5/lib/parser/open-element-stack");
|
||||
|
||||
const openElementStackOriginalPush = OpenElementStack.prototype.push;
|
||||
OpenElementStack.prototype.push = function (...args) {
|
||||
openElementStackOriginalPush.apply(this, args);
|
||||
this.treeAdapter._currentElement = this.current;
|
||||
|
||||
const after = this.items[this.stackTop];
|
||||
if (after._pushedOnStackOfOpenElements) {
|
||||
after._pushedOnStackOfOpenElements();
|
||||
}
|
||||
};
|
||||
|
||||
const openElementStackOriginalPop = OpenElementStack.prototype.pop;
|
||||
OpenElementStack.prototype.pop = function (...args) {
|
||||
const before = this.items[this.stackTop];
|
||||
|
||||
openElementStackOriginalPop.apply(this, args);
|
||||
this.treeAdapter._currentElement = this.current;
|
||||
|
||||
if (before._poppedOffStackOfOpenElements) {
|
||||
before._poppedOffStackOfOpenElements();
|
||||
}
|
||||
};
|
||||
|
||||
class JSDOMParse5Adapter {
|
||||
constructor(documentImpl, options = {}) {
|
||||
this._documentImpl = documentImpl;
|
||||
this._globalObject = documentImpl._globalObject;
|
||||
this._fragment = options.fragment || false;
|
||||
|
||||
// Since the createElement hook doesn't provide the parent element, we keep track of this using _currentElement:
|
||||
// https://github.com/inikulin/parse5/issues/285. See above horrible monkey-patch for how this is maintained.
|
||||
this._currentElement = undefined;
|
||||
}
|
||||
|
||||
_ownerDocument() {
|
||||
const { _currentElement } = this;
|
||||
|
||||
// The _currentElement is undefined when parsing elements at the root of the document.
|
||||
if (_currentElement) {
|
||||
return _currentElement.localName === "template" ?
|
||||
_currentElement.content._ownerDocument :
|
||||
_currentElement._ownerDocument;
|
||||
}
|
||||
|
||||
return this._documentImpl;
|
||||
}
|
||||
|
||||
createDocument() {
|
||||
// parse5's model assumes that parse(html) will call into here to create the new Document, then return it. However,
|
||||
// jsdom's model assumes we can create a Window (and through that create an empty Document), do some other setup
|
||||
// stuff, and then parse, stuffing nodes into that Document as we go. So to adapt between these two models, we just
|
||||
// return the already-created Document when asked by parse5 to "create" a Document.
|
||||
return this._documentImpl;
|
||||
}
|
||||
|
||||
createDocumentFragment() {
|
||||
const ownerDocument = this._ownerDocument();
|
||||
return DocumentFragment.createImpl(this._globalObject, [], { ownerDocument });
|
||||
}
|
||||
|
||||
// https://html.spec.whatwg.org/#create-an-element-for-the-token
|
||||
createElement(localName, namespace, attrs) {
|
||||
const ownerDocument = this._ownerDocument();
|
||||
|
||||
const isAttribute = attrs.find(attr => attr.name === "is");
|
||||
const isValue = isAttribute ? isAttribute.value : null;
|
||||
|
||||
const definition = lookupCEDefinition(ownerDocument, namespace, localName);
|
||||
|
||||
let willExecuteScript = false;
|
||||
if (definition !== null && !this._fragment) {
|
||||
willExecuteScript = true;
|
||||
}
|
||||
|
||||
if (willExecuteScript) {
|
||||
ownerDocument._throwOnDynamicMarkupInsertionCounter++;
|
||||
customElementReactionsStack.push([]);
|
||||
}
|
||||
|
||||
const element = createElement(ownerDocument, localName, namespace, null, isValue, willExecuteScript);
|
||||
this.adoptAttributes(element, attrs);
|
||||
|
||||
if (willExecuteScript) {
|
||||
const queue = customElementReactionsStack.pop();
|
||||
invokeCEReactions(queue);
|
||||
ownerDocument._throwOnDynamicMarkupInsertionCounter--;
|
||||
}
|
||||
|
||||
if ("_parserInserted" in element) {
|
||||
element._parserInserted = true;
|
||||
}
|
||||
|
||||
return element;
|
||||
}
|
||||
|
||||
createCommentNode(data) {
|
||||
const ownerDocument = this._ownerDocument();
|
||||
return Comment.createImpl(this._globalObject, [], { data, ownerDocument });
|
||||
}
|
||||
|
||||
appendChild(parentNode, newNode) {
|
||||
parentNode._append(newNode);
|
||||
}
|
||||
|
||||
insertBefore(parentNode, newNode, referenceNode) {
|
||||
parentNode._insert(newNode, referenceNode);
|
||||
}
|
||||
|
||||
setTemplateContent(templateElement, contentFragment) {
|
||||
// This code makes the glue between jsdom and parse5 HTMLTemplateElement parsing:
|
||||
//
|
||||
// * jsdom during the construction of the HTMLTemplateElement (for example when create via
|
||||
// `document.createElement("template")`), creates a DocumentFragment and set it into _templateContents.
|
||||
// * parse5 when parsing a <template> tag creates an HTMLTemplateElement (`createElement` adapter hook) and also
|
||||
// create a DocumentFragment (`createDocumentFragment` adapter hook).
|
||||
//
|
||||
// At this point we now have to replace the one created in jsdom with one created by parse5.
|
||||
const { _ownerDocument, _host } = templateElement._templateContents;
|
||||
contentFragment._ownerDocument = _ownerDocument;
|
||||
contentFragment._host = _host;
|
||||
|
||||
templateElement._templateContents = contentFragment;
|
||||
}
|
||||
|
||||
setDocumentType(document, name, publicId, systemId) {
|
||||
const ownerDocument = this._ownerDocument();
|
||||
const documentType = DocumentType.createImpl(this._globalObject, [], { name, publicId, systemId, ownerDocument });
|
||||
|
||||
document._append(documentType);
|
||||
}
|
||||
|
||||
setDocumentMode(document, mode) {
|
||||
// TODO: the rest of jsdom ignores this
|
||||
document._mode = mode;
|
||||
}
|
||||
|
||||
detachNode(node) {
|
||||
node.remove();
|
||||
}
|
||||
|
||||
insertText(parentNode, text) {
|
||||
const { lastChild } = parentNode;
|
||||
if (lastChild && lastChild.nodeType === nodeTypes.TEXT_NODE) {
|
||||
lastChild.data += text;
|
||||
} else {
|
||||
const ownerDocument = this._ownerDocument();
|
||||
const textNode = Text.createImpl(this._globalObject, [], { data: text, ownerDocument });
|
||||
parentNode._append(textNode);
|
||||
}
|
||||
}
|
||||
|
||||
insertTextBefore(parentNode, text, referenceNode) {
|
||||
const { previousSibling } = referenceNode;
|
||||
if (previousSibling && previousSibling.nodeType === nodeTypes.TEXT_NODE) {
|
||||
previousSibling.data += text;
|
||||
} else {
|
||||
const ownerDocument = this._ownerDocument();
|
||||
const textNode = Text.createImpl(this._globalObject, [], { data: text, ownerDocument });
|
||||
parentNode._append(textNode, referenceNode);
|
||||
}
|
||||
}
|
||||
|
||||
adoptAttributes(element, attrs) {
|
||||
for (const attr of attrs) {
|
||||
const prefix = attr.prefix === "" ? null : attr.prefix;
|
||||
attributes.setAttributeValue(element, attr.name, attr.value, prefix, attr.namespace);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Assign shared adapters with serializer.
|
||||
Object.assign(JSDOMParse5Adapter.prototype, serializationAdapter);
|
||||
|
||||
function parseFragment(markup, contextElement) {
|
||||
const ownerDocument = contextElement.localName === "template" ?
|
||||
contextElement.content._ownerDocument :
|
||||
contextElement._ownerDocument;
|
||||
|
||||
const config = Object.assign({}, ownerDocument._parseOptions, {
|
||||
treeAdapter: new JSDOMParse5Adapter(ownerDocument, {
|
||||
fragment: true
|
||||
})
|
||||
});
|
||||
|
||||
return parse5.parseFragment(contextElement, markup, config);
|
||||
}
|
||||
|
||||
function parseIntoDocument(markup, ownerDocument) {
|
||||
const config = Object.assign({}, ownerDocument._parseOptions, {
|
||||
treeAdapter: new JSDOMParse5Adapter(ownerDocument)
|
||||
});
|
||||
|
||||
return parse5.parse(markup, config);
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
parseFragment,
|
||||
parseIntoDocument
|
||||
};
|
||||
37
node_modules/jsdom/lib/jsdom/browser/parser/index.js
generated
vendored
Normal file
37
node_modules/jsdom/lib/jsdom/browser/parser/index.js
generated
vendored
Normal file
@@ -0,0 +1,37 @@
|
||||
"use strict";
|
||||
|
||||
const xmlParser = require("./xml");
|
||||
const htmlParser = require("./html");
|
||||
|
||||
// https://w3c.github.io/DOM-Parsing/#dfn-fragment-parsing-algorithm
|
||||
function parseFragment(markup, contextElement) {
|
||||
const { _parsingMode } = contextElement._ownerDocument;
|
||||
|
||||
let parseAlgorithm;
|
||||
if (_parsingMode === "html") {
|
||||
parseAlgorithm = htmlParser.parseFragment;
|
||||
} else if (_parsingMode === "xml") {
|
||||
parseAlgorithm = xmlParser.parseFragment;
|
||||
}
|
||||
|
||||
// Note: HTML and XML fragment parsing algorithm already return a document fragments; no need to do steps 3 and 4
|
||||
return parseAlgorithm(markup, contextElement);
|
||||
}
|
||||
|
||||
function parseIntoDocument(markup, ownerDocument) {
|
||||
const { _parsingMode } = ownerDocument;
|
||||
|
||||
let parseAlgorithm;
|
||||
if (_parsingMode === "html") {
|
||||
parseAlgorithm = htmlParser.parseIntoDocument;
|
||||
} else if (_parsingMode === "xml") {
|
||||
parseAlgorithm = xmlParser.parseIntoDocument;
|
||||
}
|
||||
|
||||
return parseAlgorithm(markup, ownerDocument);
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
parseFragment,
|
||||
parseIntoDocument
|
||||
};
|
||||
205
node_modules/jsdom/lib/jsdom/browser/parser/xml.js
generated
vendored
Normal file
205
node_modules/jsdom/lib/jsdom/browser/parser/xml.js
generated
vendored
Normal file
@@ -0,0 +1,205 @@
|
||||
"use strict";
|
||||
|
||||
const { SaxesParser } = require("saxes");
|
||||
const DOMException = require("domexception/webidl2js-wrapper");
|
||||
|
||||
const { createElement } = require("../../living/helpers/create-element");
|
||||
|
||||
const DocumentFragment = require("../../living/generated/DocumentFragment");
|
||||
const DocumentType = require("../../living/generated/DocumentType");
|
||||
const CDATASection = require("../../living/generated/CDATASection");
|
||||
const Comment = require("../../living/generated/Comment");
|
||||
const ProcessingInstruction = require("../../living/generated/ProcessingInstruction");
|
||||
const Text = require("../../living/generated/Text");
|
||||
|
||||
const attributes = require("../../living/attributes");
|
||||
const { HTML_NS } = require("../../living/helpers/namespaces");
|
||||
|
||||
const HTML5_DOCTYPE = /<!doctype html>/i;
|
||||
const PUBLIC_DOCTYPE = /<!doctype\s+([^\s]+)\s+public\s+"([^"]+)"\s+"([^"]+)"/i;
|
||||
const SYSTEM_DOCTYPE = /<!doctype\s+([^\s]+)\s+system\s+"([^"]+)"/i;
|
||||
const CUSTOM_NAME_DOCTYPE = /<!doctype\s+([^\s>]+)/i;
|
||||
|
||||
function parseDocType(globalObject, ownerDocument, html) {
|
||||
if (HTML5_DOCTYPE.test(html)) {
|
||||
return createDocumentType(globalObject, ownerDocument, "html", "", "");
|
||||
}
|
||||
|
||||
const publicPieces = PUBLIC_DOCTYPE.exec(html);
|
||||
if (publicPieces) {
|
||||
return createDocumentType(globalObject, ownerDocument, publicPieces[1], publicPieces[2], publicPieces[3]);
|
||||
}
|
||||
|
||||
const systemPieces = SYSTEM_DOCTYPE.exec(html);
|
||||
if (systemPieces) {
|
||||
return createDocumentType(globalObject, ownerDocument, systemPieces[1], "", systemPieces[2]);
|
||||
}
|
||||
|
||||
const namePiece = CUSTOM_NAME_DOCTYPE.exec(html)[1] || "html";
|
||||
return createDocumentType(globalObject, ownerDocument, namePiece, "", "");
|
||||
}
|
||||
|
||||
function createDocumentType(globalObject, ownerDocument, name, publicId, systemId) {
|
||||
return DocumentType.createImpl(globalObject, [], { ownerDocument, name, publicId, systemId });
|
||||
}
|
||||
|
||||
function isHTMLTemplateElement(element) {
|
||||
return element.tagName === "template" && element.namespaceURI === HTML_NS;
|
||||
}
|
||||
|
||||
|
||||
function createParser(rootNode, globalObject, saxesOptions) {
|
||||
const parser = new SaxesParser({
|
||||
...saxesOptions,
|
||||
// Browsers always have namespace support.
|
||||
xmlns: true,
|
||||
// We force the parser to treat all documents (even documents declaring themselves to be XML 1.1 documents) as XML
|
||||
// 1.0 documents. See https://github.com/jsdom/jsdom/issues/2677 for a discussion of the stakes.
|
||||
defaultXMLVersion: "1.0",
|
||||
forceXMLVersion: true
|
||||
});
|
||||
const openStack = [rootNode];
|
||||
|
||||
function getOwnerDocument() {
|
||||
const currentElement = openStack[openStack.length - 1];
|
||||
|
||||
return isHTMLTemplateElement(currentElement) ?
|
||||
currentElement._templateContents._ownerDocument :
|
||||
currentElement._ownerDocument;
|
||||
}
|
||||
|
||||
function appendChild(child) {
|
||||
const parentElement = openStack[openStack.length - 1];
|
||||
|
||||
if (isHTMLTemplateElement(parentElement)) {
|
||||
parentElement._templateContents._insert(child, null);
|
||||
} else {
|
||||
parentElement._insert(child, null);
|
||||
}
|
||||
}
|
||||
|
||||
parser.on("text", saxesOptions.fragment ?
|
||||
// In a fragment, all text events produced by saxes must result in a text
|
||||
// node.
|
||||
data => {
|
||||
const ownerDocument = getOwnerDocument();
|
||||
appendChild(Text.createImpl(globalObject, [], { data, ownerDocument }));
|
||||
} :
|
||||
// When parsing a whole document, we must ignore those text nodes that are
|
||||
// produced outside the root element. Saxes produces events for them,
|
||||
// but DOM trees do not record text outside the root element.
|
||||
data => {
|
||||
if (openStack.length > 1) {
|
||||
const ownerDocument = getOwnerDocument();
|
||||
appendChild(Text.createImpl(globalObject, [], { data, ownerDocument }));
|
||||
}
|
||||
});
|
||||
|
||||
parser.on("cdata", data => {
|
||||
const ownerDocument = getOwnerDocument();
|
||||
appendChild(CDATASection.createImpl(globalObject, [], { data, ownerDocument }));
|
||||
});
|
||||
|
||||
parser.on("opentag", tag => {
|
||||
const { local: tagLocal, attributes: tagAttributes } = tag;
|
||||
|
||||
const ownerDocument = getOwnerDocument();
|
||||
const tagNamespace = tag.uri === "" ? null : tag.uri;
|
||||
const tagPrefix = tag.prefix === "" ? null : tag.prefix;
|
||||
const isValue = tagAttributes.is === undefined ? null : tagAttributes.is.value;
|
||||
|
||||
const elem = createElement(ownerDocument, tagLocal, tagNamespace, tagPrefix, isValue, true);
|
||||
|
||||
// We mark a script element as "parser-inserted", which prevents it from
|
||||
// being immediately executed.
|
||||
if (tagLocal === "script" && tagNamespace === HTML_NS) {
|
||||
elem._parserInserted = true;
|
||||
}
|
||||
|
||||
for (const key of Object.keys(tagAttributes)) {
|
||||
const { prefix, local, uri, value } = tagAttributes[key];
|
||||
attributes.setAttributeValue(
|
||||
elem, local, value, prefix === "" ? null : prefix,
|
||||
uri === "" ? null : uri
|
||||
);
|
||||
}
|
||||
|
||||
appendChild(elem);
|
||||
openStack.push(elem);
|
||||
});
|
||||
|
||||
parser.on("closetag", () => {
|
||||
const elem = openStack.pop();
|
||||
// Once a script is populated, we can execute it.
|
||||
if (elem.localName === "script" && elem.namespaceURI === HTML_NS) {
|
||||
elem._eval();
|
||||
}
|
||||
});
|
||||
|
||||
parser.on("comment", data => {
|
||||
const ownerDocument = getOwnerDocument();
|
||||
appendChild(Comment.createImpl(globalObject, [], { data, ownerDocument }));
|
||||
});
|
||||
|
||||
parser.on("processinginstruction", ({ target, body }) => {
|
||||
const ownerDocument = getOwnerDocument();
|
||||
appendChild(ProcessingInstruction.createImpl(globalObject, [], { target, data: body, ownerDocument }));
|
||||
});
|
||||
|
||||
parser.on("doctype", dt => {
|
||||
const ownerDocument = getOwnerDocument();
|
||||
appendChild(parseDocType(globalObject, ownerDocument, `<!doctype ${dt}>`));
|
||||
|
||||
const entityMatcher = /<!ENTITY ([^ ]+) "([^"]+)">/g;
|
||||
let result;
|
||||
while ((result = entityMatcher.exec(dt))) {
|
||||
const [, name, value] = result;
|
||||
if (!(name in parser.ENTITIES)) {
|
||||
parser.ENTITIES[name] = value;
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
parser.on("error", err => {
|
||||
throw DOMException.create(globalObject, [err.message, "SyntaxError"]);
|
||||
});
|
||||
|
||||
return parser;
|
||||
}
|
||||
|
||||
function parseFragment(markup, contextElement) {
|
||||
const { _globalObject, _ownerDocument } = contextElement;
|
||||
|
||||
const fragment = DocumentFragment.createImpl(_globalObject, [], { ownerDocument: _ownerDocument });
|
||||
|
||||
// Only parseFragment needs resolvePrefix per the saxes documentation:
|
||||
// https://github.com/lddubeau/saxes#parsing-xml-fragments
|
||||
const parser = createParser(fragment, _globalObject, {
|
||||
fragment: true,
|
||||
resolvePrefix(prefix) {
|
||||
// saxes wants undefined as the return value if the prefix is not defined, not null.
|
||||
return contextElement.lookupNamespaceURI(prefix) || undefined;
|
||||
}
|
||||
});
|
||||
|
||||
parser.write(markup).close();
|
||||
|
||||
return fragment;
|
||||
}
|
||||
|
||||
function parseIntoDocument(markup, ownerDocument) {
|
||||
const { _globalObject } = ownerDocument;
|
||||
|
||||
const parser = createParser(ownerDocument, _globalObject, {
|
||||
fileName: ownerDocument.location && ownerDocument.location.href
|
||||
});
|
||||
|
||||
parser.write(markup).close();
|
||||
|
||||
return ownerDocument;
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
parseFragment,
|
||||
parseIntoDocument
|
||||
};
|
||||
275
node_modules/jsdom/lib/jsdom/browser/resource-loader.js
generated
vendored
275
node_modules/jsdom/lib/jsdom/browser/resource-loader.js
generated
vendored
@@ -1,275 +0,0 @@
|
||||
"use strict";
|
||||
|
||||
const MIMEType = require("whatwg-mimetype");
|
||||
const parseDataURL = require("data-urls");
|
||||
const sniffHTMLEncoding = require("html-encoding-sniffer");
|
||||
const whatwgEncoding = require("whatwg-encoding");
|
||||
const fs = require("fs");
|
||||
const request = require("request");
|
||||
const { documentBaseURLSerialized } = require("../living/helpers/document-base-url");
|
||||
const NODE_TYPE = require("../living/node-type");
|
||||
|
||||
/* eslint-disable no-restricted-modules */
|
||||
// TODO: stop using the built-in URL in favor of the spec-compliant whatwg-url package
|
||||
// This legacy usage is in the process of being purged.
|
||||
const URL = require("url");
|
||||
/* eslint-enable no-restricted-modules */
|
||||
|
||||
const IS_BROWSER = Object.prototype.toString.call(process) !== "[object process]";
|
||||
|
||||
function createResourceLoadHandler(element, resourceUrl, document, loadCallback) {
|
||||
if (loadCallback === undefined) {
|
||||
loadCallback = () => {
|
||||
// do nothing
|
||||
};
|
||||
}
|
||||
return (err, data, response) => {
|
||||
const ev = document.createEvent("HTMLEvents");
|
||||
|
||||
if (!err) {
|
||||
try {
|
||||
loadCallback.call(element, data, resourceUrl, response);
|
||||
ev.initEvent("load", false, false);
|
||||
} catch (e) {
|
||||
err = e;
|
||||
}
|
||||
}
|
||||
|
||||
if (err) {
|
||||
if (!err.isAbortError) {
|
||||
ev.initEvent("error", false, false);
|
||||
ev.error = err;
|
||||
element.dispatchEvent(ev);
|
||||
|
||||
const error = new Error(`Could not load ${element.localName}: "${resourceUrl}"`);
|
||||
error.detail = err;
|
||||
error.type = "resource loading";
|
||||
|
||||
document._defaultView._virtualConsole.emit("jsdomError", error);
|
||||
}
|
||||
} else {
|
||||
element.dispatchEvent(ev);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
exports.readFile = function (filePath, { defaultEncoding, detectMetaCharset }, callback) {
|
||||
const readableStream = fs.createReadStream(filePath);
|
||||
|
||||
let data = Buffer.alloc(0);
|
||||
|
||||
readableStream.on("error", callback);
|
||||
|
||||
readableStream.on("data", chunk => {
|
||||
data = Buffer.concat([data, chunk]);
|
||||
});
|
||||
|
||||
readableStream.on("end", () => {
|
||||
// Not passing default encoding means binary
|
||||
if (defaultEncoding) {
|
||||
const encoding = detectMetaCharset ?
|
||||
sniffHTMLEncoding(data, { defaultEncoding }) :
|
||||
whatwgEncoding.getBOMEncoding(data) || defaultEncoding;
|
||||
const decoded = whatwgEncoding.decode(data, encoding);
|
||||
callback(null, decoded, { headers: { "content-type": "text/plain;charset=" + encoding } });
|
||||
} else {
|
||||
callback(null, data);
|
||||
}
|
||||
});
|
||||
|
||||
return {
|
||||
abort() {
|
||||
readableStream.destroy();
|
||||
const error = new Error("request canceled by user");
|
||||
error.isAbortError = true;
|
||||
callback(error);
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
function readDataURL(dataURL, { defaultEncoding, detectMetaCharset }, callback) {
|
||||
try {
|
||||
const parsed = parseDataURL(dataURL);
|
||||
// If default encoding does not exist, pass on binary data.
|
||||
if (defaultEncoding) {
|
||||
const sniffOptions = {
|
||||
transportLayerEncodingLabel: parsed.mimeType.parameters.get("charset"),
|
||||
defaultEncoding
|
||||
};
|
||||
|
||||
const encoding = detectMetaCharset ?
|
||||
sniffHTMLEncoding(parsed.body, sniffOptions) :
|
||||
whatwgEncoding.getBOMEncoding(parsed.body) ||
|
||||
whatwgEncoding.labelToName(parsed.mimeType.parameters.get("charset")) ||
|
||||
defaultEncoding;
|
||||
const decoded = whatwgEncoding.decode(parsed.body, encoding);
|
||||
|
||||
parsed.mimeType.parameters.set("charset", encoding);
|
||||
|
||||
callback(null, decoded, { headers: { "content-type": parsed.mimeType.toString() } });
|
||||
} else {
|
||||
callback(null, parsed.body, { headers: { "content-type": parsed.mimeType.toString() } });
|
||||
}
|
||||
} catch (err) {
|
||||
callback(err, null);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
// NOTE: request wraps tough-cookie cookie jar
|
||||
// (see: https://github.com/request/request/blob/master/lib/cookies.js).
|
||||
// Therefore, to pass our cookie jar to the request, we need to create
|
||||
// request's wrapper and monkey patch it with our jar.
|
||||
exports.wrapCookieJarForRequest = cookieJar => {
|
||||
const jarWrapper = request.jar();
|
||||
jarWrapper._jar = cookieJar;
|
||||
return jarWrapper;
|
||||
};
|
||||
|
||||
function fetch(urlObj, options, callback) {
|
||||
if (urlObj.protocol === "data:") {
|
||||
return readDataURL(urlObj.href, options, callback);
|
||||
} else if (urlObj.hostname) {
|
||||
return exports.download(urlObj, options, callback);
|
||||
}
|
||||
const filePath = urlObj.pathname
|
||||
.replace(/^file:\/\//, "")
|
||||
.replace(/^\/([a-z]):\//i, "$1:/")
|
||||
.replace(/%20/g, " ");
|
||||
return exports.readFile(filePath, options, callback);
|
||||
}
|
||||
|
||||
exports.enqueue = function (element, resourceUrl, callback) {
|
||||
const document = element.nodeType === NODE_TYPE.DOCUMENT_NODE ? element : element._ownerDocument;
|
||||
|
||||
if (document._queue) {
|
||||
const loadHandler = createResourceLoadHandler(element, resourceUrl || document.URL, document, callback);
|
||||
return document._queue.push(loadHandler);
|
||||
}
|
||||
|
||||
return () => {
|
||||
// do nothing in queue-less documents
|
||||
};
|
||||
};
|
||||
|
||||
exports.download = function (url, options, callback) {
|
||||
const requestOptions = {
|
||||
pool: options.pool,
|
||||
agent: options.agent,
|
||||
agentOptions: options.agentOptions,
|
||||
agentClass: options.agentClass,
|
||||
strictSSL: options.strictSSL,
|
||||
gzip: true,
|
||||
jar: exports.wrapCookieJarForRequest(options.cookieJar),
|
||||
encoding: null,
|
||||
headers: {
|
||||
"User-Agent": options.userAgent,
|
||||
"Accept-Language": "en",
|
||||
Accept: options.accept || "*/*"
|
||||
}
|
||||
};
|
||||
if (options.referrer && !IS_BROWSER) {
|
||||
requestOptions.headers.referer = options.referrer;
|
||||
}
|
||||
if (options.proxy) {
|
||||
requestOptions.proxy = options.proxy;
|
||||
}
|
||||
Object.assign(requestOptions.headers, options.headers);
|
||||
|
||||
const { defaultEncoding, detectMetaCharset } = options;
|
||||
|
||||
const req = request(url, requestOptions, (error, response, bufferData) => {
|
||||
if (!error) {
|
||||
// If default encoding does not exist, pass on binary data.
|
||||
if (defaultEncoding) {
|
||||
const contentType = MIMEType.parse(response.headers["content-type"]) || new MIMEType("text/plain");
|
||||
const sniffOptions = {
|
||||
transportLayerEncodingLabel: contentType.parameters.get("charset"),
|
||||
defaultEncoding
|
||||
};
|
||||
|
||||
const encoding = detectMetaCharset ?
|
||||
sniffHTMLEncoding(bufferData, sniffOptions) :
|
||||
whatwgEncoding.getBOMEncoding(bufferData) ||
|
||||
whatwgEncoding.labelToName(contentType.parameters.get("charset")) ||
|
||||
defaultEncoding;
|
||||
const decoded = whatwgEncoding.decode(bufferData, encoding);
|
||||
|
||||
contentType.parameters.set("charset", encoding);
|
||||
response.headers["content-type"] = contentType.toString();
|
||||
|
||||
callback(null, decoded, response);
|
||||
} else {
|
||||
callback(null, bufferData, response);
|
||||
}
|
||||
} else {
|
||||
callback(error, null, response);
|
||||
}
|
||||
});
|
||||
return {
|
||||
abort() {
|
||||
req.abort();
|
||||
const error = new Error("request canceled by user");
|
||||
error.isAbortError = true;
|
||||
callback(error);
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
exports.load = function (element, urlString, options, callback) {
|
||||
const document = element._ownerDocument;
|
||||
const documentImpl = document.implementation;
|
||||
|
||||
if (!documentImpl._hasFeature("FetchExternalResources", element.tagName.toLowerCase())) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (documentImpl._hasFeature("SkipExternalResources", urlString)) {
|
||||
return;
|
||||
}
|
||||
|
||||
const urlObj = URL.parse(urlString);
|
||||
const enqueued = exports.enqueue(element, urlString, callback);
|
||||
const customLoader = document._customResourceLoader;
|
||||
const requestManager = document._requestManager;
|
||||
const cookieJar = document._cookieJar;
|
||||
|
||||
options.accept = element._accept;
|
||||
options.cookieJar = cookieJar;
|
||||
options.referrer = document.URL;
|
||||
options.pool = document._pool;
|
||||
options.agentOptions = document._agentOptions;
|
||||
options.strictSSL = document._strictSSL;
|
||||
options.proxy = document._proxy;
|
||||
options.userAgent = document._defaultView.navigator.userAgent;
|
||||
|
||||
let req = null;
|
||||
function wrappedEnqueued() {
|
||||
if (req && requestManager) {
|
||||
requestManager.remove(req);
|
||||
}
|
||||
// do not trigger if the window is closed
|
||||
if (element._ownerDocument && element._ownerDocument.defaultView.document) {
|
||||
enqueued.apply(this, arguments);
|
||||
}
|
||||
}
|
||||
if (typeof customLoader === "function") {
|
||||
req = customLoader(
|
||||
{
|
||||
element,
|
||||
url: urlObj,
|
||||
cookie: cookieJar.getCookieStringSync(urlObj, { http: true }),
|
||||
baseUrl: documentBaseURLSerialized(document),
|
||||
defaultFetch(fetchCallback) {
|
||||
return fetch(urlObj, options, fetchCallback);
|
||||
}
|
||||
},
|
||||
wrappedEnqueued
|
||||
);
|
||||
} else {
|
||||
req = fetch(urlObj, options, wrappedEnqueued);
|
||||
}
|
||||
if (req && requestManager) {
|
||||
requestManager.add(req);
|
||||
}
|
||||
};
|
||||
114
node_modules/jsdom/lib/jsdom/browser/resources/async-resource-queue.js
generated
vendored
Normal file
114
node_modules/jsdom/lib/jsdom/browser/resources/async-resource-queue.js
generated
vendored
Normal file
@@ -0,0 +1,114 @@
|
||||
"use strict";
|
||||
|
||||
class QueueItem {
|
||||
constructor(onLoad, onError, dependentItem) {
|
||||
this.onLoad = onLoad;
|
||||
this.onError = onError;
|
||||
this.data = null;
|
||||
this.error = null;
|
||||
this.dependentItem = dependentItem;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* AsyncResourceQueue is the queue in charge of run the async scripts
|
||||
* and notify when they finish.
|
||||
*/
|
||||
module.exports = class AsyncResourceQueue {
|
||||
constructor() {
|
||||
this.items = new Set();
|
||||
this.dependentItems = new Set();
|
||||
}
|
||||
|
||||
count() {
|
||||
return this.items.size + this.dependentItems.size;
|
||||
}
|
||||
|
||||
_notify() {
|
||||
if (this._listener) {
|
||||
this._listener();
|
||||
}
|
||||
}
|
||||
|
||||
_check(item) {
|
||||
let promise;
|
||||
|
||||
if (item.onError && item.error) {
|
||||
promise = item.onError(item.error);
|
||||
} else if (item.onLoad && item.data) {
|
||||
promise = item.onLoad(item.data);
|
||||
}
|
||||
|
||||
promise
|
||||
.then(() => {
|
||||
this.items.delete(item);
|
||||
this.dependentItems.delete(item);
|
||||
|
||||
if (this.count() === 0) {
|
||||
this._notify();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
setListener(listener) {
|
||||
this._listener = listener;
|
||||
}
|
||||
|
||||
push(request, onLoad, onError, dependentItem) {
|
||||
const q = this;
|
||||
|
||||
const item = new QueueItem(onLoad, onError, dependentItem);
|
||||
|
||||
q.items.add(item);
|
||||
|
||||
return request
|
||||
.then(data => {
|
||||
item.data = data;
|
||||
|
||||
if (dependentItem && !dependentItem.finished) {
|
||||
q.dependentItems.add(item);
|
||||
return q.items.delete(item);
|
||||
}
|
||||
|
||||
if (onLoad) {
|
||||
return q._check(item);
|
||||
}
|
||||
|
||||
q.items.delete(item);
|
||||
|
||||
if (q.count() === 0) {
|
||||
q._notify();
|
||||
}
|
||||
|
||||
return null;
|
||||
})
|
||||
.catch(err => {
|
||||
item.error = err;
|
||||
|
||||
if (dependentItem && !dependentItem.finished) {
|
||||
q.dependentItems.add(item);
|
||||
return q.items.delete(item);
|
||||
}
|
||||
|
||||
if (onError) {
|
||||
return q._check(item);
|
||||
}
|
||||
|
||||
q.items.delete(item);
|
||||
|
||||
if (q.count() === 0) {
|
||||
q._notify();
|
||||
}
|
||||
|
||||
return null;
|
||||
});
|
||||
}
|
||||
|
||||
notifyItem(syncItem) {
|
||||
for (const item of this.dependentItems) {
|
||||
if (item.dependentItem === syncItem) {
|
||||
this._check(item);
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
8
node_modules/jsdom/lib/jsdom/browser/resources/no-op-resource-loader.js
generated
vendored
Normal file
8
node_modules/jsdom/lib/jsdom/browser/resources/no-op-resource-loader.js
generated
vendored
Normal file
@@ -0,0 +1,8 @@
|
||||
"use strict";
|
||||
const ResourceLoader = require("./resource-loader.js");
|
||||
|
||||
module.exports = class NoOpResourceLoader extends ResourceLoader {
|
||||
fetch() {
|
||||
return null;
|
||||
}
|
||||
};
|
||||
95
node_modules/jsdom/lib/jsdom/browser/resources/per-document-resource-loader.js
generated
vendored
Normal file
95
node_modules/jsdom/lib/jsdom/browser/resources/per-document-resource-loader.js
generated
vendored
Normal file
@@ -0,0 +1,95 @@
|
||||
"use strict";
|
||||
const idlUtils = require("../../living/generated/utils");
|
||||
const { fireAnEvent } = require("../../living/helpers/events");
|
||||
|
||||
module.exports = class PerDocumentResourceLoader {
|
||||
constructor(document) {
|
||||
this._document = document;
|
||||
this._defaultEncoding = document._encoding;
|
||||
this._resourceLoader = document._defaultView ? document._defaultView._resourceLoader : null;
|
||||
this._requestManager = document._requestManager;
|
||||
this._queue = document._queue;
|
||||
this._deferQueue = document._deferQueue;
|
||||
this._asyncQueue = document._asyncQueue;
|
||||
}
|
||||
|
||||
fetch(url, { element, onLoad, onError }) {
|
||||
const request = this._resourceLoader.fetch(url, {
|
||||
cookieJar: this._document._cookieJar,
|
||||
element: idlUtils.wrapperForImpl(element),
|
||||
referrer: this._document.URL
|
||||
});
|
||||
|
||||
if (request === null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
this._requestManager.add(request);
|
||||
|
||||
const onErrorWrapped = error => {
|
||||
this._requestManager.remove(request);
|
||||
|
||||
if (onError) {
|
||||
onError(error);
|
||||
}
|
||||
|
||||
fireAnEvent("error", element);
|
||||
|
||||
const err = new Error(`Could not load ${element.localName}: "${url}"`);
|
||||
err.type = "resource loading";
|
||||
err.detail = error;
|
||||
|
||||
this._document._defaultView._virtualConsole.emit("jsdomError", err);
|
||||
|
||||
return Promise.resolve();
|
||||
};
|
||||
|
||||
const onLoadWrapped = data => {
|
||||
this._requestManager.remove(request);
|
||||
|
||||
this._addCookies(url, request.response ? request.response.headers : {});
|
||||
|
||||
try {
|
||||
const result = onLoad ? onLoad(data) : undefined;
|
||||
|
||||
return Promise.resolve(result)
|
||||
.then(() => {
|
||||
fireAnEvent("load", element);
|
||||
|
||||
return Promise.resolve();
|
||||
})
|
||||
.catch(err => {
|
||||
return onErrorWrapped(err);
|
||||
});
|
||||
} catch (err) {
|
||||
return onErrorWrapped(err);
|
||||
}
|
||||
};
|
||||
|
||||
if (element.localName === "script" && element.hasAttributeNS(null, "async")) {
|
||||
this._asyncQueue.push(request, onLoadWrapped, onErrorWrapped, this._queue.getLastScript());
|
||||
} else if (element.localName === "script" && element.hasAttributeNS(null, "defer")) {
|
||||
this._deferQueue.push(request, onLoadWrapped, onErrorWrapped, false, element);
|
||||
} else {
|
||||
this._queue.push(request, onLoadWrapped, onErrorWrapped, false, element);
|
||||
}
|
||||
|
||||
return request;
|
||||
}
|
||||
|
||||
_addCookies(url, headers) {
|
||||
let cookies = headers["set-cookie"];
|
||||
|
||||
if (!cookies) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!Array.isArray(cookies)) {
|
||||
cookies = [cookies];
|
||||
}
|
||||
|
||||
cookies.forEach(cookie => {
|
||||
this._document._cookieJar.setCookieSync(cookie, url, { http: true, ignoreError: true });
|
||||
});
|
||||
}
|
||||
};
|
||||
33
node_modules/jsdom/lib/jsdom/browser/resources/request-manager.js
generated
vendored
Normal file
33
node_modules/jsdom/lib/jsdom/browser/resources/request-manager.js
generated
vendored
Normal file
@@ -0,0 +1,33 @@
|
||||
"use strict";
|
||||
|
||||
/**
|
||||
* Manage all the request and it is able to abort
|
||||
* all pending request.
|
||||
*/
|
||||
module.exports = class RequestManager {
|
||||
constructor() {
|
||||
this.openedRequests = [];
|
||||
}
|
||||
|
||||
add(req) {
|
||||
this.openedRequests.push(req);
|
||||
}
|
||||
|
||||
remove(req) {
|
||||
const idx = this.openedRequests.indexOf(req);
|
||||
if (idx !== -1) {
|
||||
this.openedRequests.splice(idx, 1);
|
||||
}
|
||||
}
|
||||
|
||||
close() {
|
||||
for (const openedRequest of this.openedRequests) {
|
||||
openedRequest.abort();
|
||||
}
|
||||
this.openedRequests = [];
|
||||
}
|
||||
|
||||
size() {
|
||||
return this.openedRequests.length;
|
||||
}
|
||||
};
|
||||
127
node_modules/jsdom/lib/jsdom/browser/resources/resource-loader.js
generated
vendored
Normal file
127
node_modules/jsdom/lib/jsdom/browser/resources/resource-loader.js
generated
vendored
Normal file
@@ -0,0 +1,127 @@
|
||||
"use strict";
|
||||
const fs = require("fs");
|
||||
const { parseURL } = require("whatwg-url");
|
||||
const dataURLFromRecord = require("data-urls").fromURLRecord;
|
||||
const request = require("request-promise-native");
|
||||
const wrapCookieJarForRequest = require("../../living/helpers/wrap-cookie-jar-for-request");
|
||||
const packageVersion = require("../../../../package.json").version;
|
||||
const IS_BROWSER = Object.prototype.toString.call(process) !== "[object process]";
|
||||
|
||||
module.exports = class ResourceLoader {
|
||||
constructor({
|
||||
strictSSL = true,
|
||||
proxy = undefined,
|
||||
userAgent = `Mozilla/5.0 (${process.platform || "unknown OS"}) AppleWebKit/537.36 ` +
|
||||
`(KHTML, like Gecko) jsdom/${packageVersion}`
|
||||
} = {}) {
|
||||
this._strictSSL = strictSSL;
|
||||
this._proxy = proxy;
|
||||
this._userAgent = userAgent;
|
||||
}
|
||||
|
||||
_readDataURL(urlRecord) {
|
||||
const dataURL = dataURLFromRecord(urlRecord);
|
||||
let timeoutId;
|
||||
const promise = new Promise(resolve => {
|
||||
timeoutId = setTimeout(resolve, 0, dataURL.body);
|
||||
});
|
||||
promise.abort = () => {
|
||||
if (timeoutId !== undefined) {
|
||||
clearTimeout(timeoutId);
|
||||
}
|
||||
};
|
||||
return promise;
|
||||
}
|
||||
|
||||
_readFile(filePath) {
|
||||
let readableStream;
|
||||
let abort; // Native Promises doesn't have an "abort" method.
|
||||
|
||||
/*
|
||||
* Creating a promise for two reason:
|
||||
* 1. fetch always return a promise.
|
||||
* 2. We need to add an abort handler.
|
||||
*/
|
||||
const promise = new Promise((resolve, reject) => {
|
||||
readableStream = fs.createReadStream(filePath);
|
||||
let data = Buffer.alloc(0);
|
||||
|
||||
abort = reject;
|
||||
|
||||
readableStream.on("error", reject);
|
||||
|
||||
readableStream.on("data", chunk => {
|
||||
data = Buffer.concat([data, chunk]);
|
||||
});
|
||||
|
||||
readableStream.on("end", () => {
|
||||
resolve(data);
|
||||
});
|
||||
});
|
||||
|
||||
promise.abort = () => {
|
||||
readableStream.destroy();
|
||||
const error = new Error("request canceled by user");
|
||||
error.isAbortError = true;
|
||||
abort(error);
|
||||
};
|
||||
|
||||
return promise;
|
||||
}
|
||||
|
||||
_getRequestOptions({ cookieJar, referrer, accept = "*/*" }) {
|
||||
const requestOptions = {
|
||||
encoding: null,
|
||||
gzip: true,
|
||||
jar: wrapCookieJarForRequest(cookieJar),
|
||||
strictSSL: this._strictSSL,
|
||||
proxy: this._proxy,
|
||||
forever: true,
|
||||
headers: {
|
||||
"User-Agent": this._userAgent,
|
||||
"Accept-Language": "en",
|
||||
Accept: accept
|
||||
}
|
||||
};
|
||||
|
||||
if (referrer && !IS_BROWSER) {
|
||||
requestOptions.headers.referer = referrer;
|
||||
}
|
||||
|
||||
return requestOptions;
|
||||
}
|
||||
|
||||
fetch(urlString, options = {}) {
|
||||
const url = parseURL(urlString);
|
||||
|
||||
if (!url) {
|
||||
return Promise.reject(new Error(`Tried to fetch invalid URL ${urlString}`));
|
||||
}
|
||||
|
||||
switch (url.scheme) {
|
||||
case "data": {
|
||||
return this._readDataURL(url);
|
||||
}
|
||||
|
||||
case "http":
|
||||
case "https": {
|
||||
const requestOptions = this._getRequestOptions(options);
|
||||
return request(urlString, requestOptions);
|
||||
}
|
||||
|
||||
case "file": {
|
||||
// TODO: Improve the URL => file algorithm. See https://github.com/jsdom/jsdom/pull/2279#discussion_r199977987
|
||||
const filePath = urlString
|
||||
.replace(/^file:\/\//, "")
|
||||
.replace(/^\/([a-z]):\//i, "$1:/")
|
||||
.replace(/%20/g, " ");
|
||||
|
||||
return this._readFile(filePath);
|
||||
}
|
||||
|
||||
default: {
|
||||
return Promise.reject(new Error(`Tried to fetch URL ${urlString} with invalid scheme ${url.scheme}`));
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
142
node_modules/jsdom/lib/jsdom/browser/resources/resource-queue.js
generated
vendored
Normal file
142
node_modules/jsdom/lib/jsdom/browser/resources/resource-queue.js
generated
vendored
Normal file
@@ -0,0 +1,142 @@
|
||||
"use strict";
|
||||
|
||||
/**
|
||||
* Queue for all the resources to be download except async scripts.
|
||||
* Async scripts have their own queue AsyncResourceQueue.
|
||||
*/
|
||||
module.exports = class ResourceQueue {
|
||||
constructor({ paused, asyncQueue } = {}) {
|
||||
this.paused = Boolean(paused);
|
||||
this._asyncQueue = asyncQueue;
|
||||
}
|
||||
|
||||
getLastScript() {
|
||||
let head = this.tail;
|
||||
|
||||
while (head) {
|
||||
if (head.isScript) {
|
||||
return head;
|
||||
}
|
||||
head = head.prev;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
_moreScripts() {
|
||||
let found = false;
|
||||
|
||||
let head = this.tail;
|
||||
while (head && !found) {
|
||||
found = head.isScript;
|
||||
head = head.prev;
|
||||
}
|
||||
|
||||
return found;
|
||||
}
|
||||
|
||||
_notify() {
|
||||
if (this._listener) {
|
||||
this._listener();
|
||||
}
|
||||
}
|
||||
|
||||
setListener(listener) {
|
||||
this._listener = listener;
|
||||
}
|
||||
|
||||
push(request, onLoad, onError, keepLast, element) {
|
||||
const isScript = element ? element.localName === "script" : false;
|
||||
|
||||
if (!request) {
|
||||
if (isScript && !this._moreScripts()) {
|
||||
return onLoad();
|
||||
}
|
||||
|
||||
request = new Promise(resolve => resolve());
|
||||
}
|
||||
const q = this;
|
||||
const item = {
|
||||
isScript,
|
||||
err: null,
|
||||
element,
|
||||
fired: false,
|
||||
data: null,
|
||||
keepLast,
|
||||
prev: q.tail,
|
||||
check() {
|
||||
if (!q.paused && !this.prev && this.fired) {
|
||||
let promise;
|
||||
|
||||
if (this.err && onError) {
|
||||
promise = onError(this.err);
|
||||
}
|
||||
|
||||
if (!this.err && onLoad) {
|
||||
promise = onLoad(this.data);
|
||||
}
|
||||
|
||||
Promise.resolve(promise)
|
||||
.then(() => {
|
||||
if (this.next) {
|
||||
this.next.prev = null;
|
||||
this.next.check();
|
||||
} else { // q.tail===this
|
||||
q.tail = null;
|
||||
q._notify();
|
||||
}
|
||||
|
||||
this.finished = true;
|
||||
|
||||
if (q._asyncQueue) {
|
||||
q._asyncQueue.notifyItem(this);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
};
|
||||
if (q.tail) {
|
||||
if (q.tail.keepLast) {
|
||||
// if the tail is the load event in document and we receive a new element to load
|
||||
// we should add this new request before the load event.
|
||||
if (q.tail.prev) {
|
||||
q.tail.prev.next = item;
|
||||
}
|
||||
item.prev = q.tail.prev;
|
||||
q.tail.prev = item;
|
||||
item.next = q.tail;
|
||||
} else {
|
||||
q.tail.next = item;
|
||||
q.tail = item;
|
||||
}
|
||||
} else {
|
||||
q.tail = item;
|
||||
}
|
||||
return request
|
||||
.then(data => {
|
||||
item.fired = 1;
|
||||
item.data = data;
|
||||
item.check();
|
||||
})
|
||||
.catch(err => {
|
||||
item.fired = true;
|
||||
item.err = err;
|
||||
item.check();
|
||||
});
|
||||
}
|
||||
|
||||
resume() {
|
||||
if (!this.paused) {
|
||||
return;
|
||||
}
|
||||
this.paused = false;
|
||||
|
||||
let head = this.tail;
|
||||
while (head && head.prev) {
|
||||
head = head.prev;
|
||||
}
|
||||
if (head) {
|
||||
head.check();
|
||||
}
|
||||
}
|
||||
};
|
||||
13
node_modules/jsdom/lib/jsdom/level2/style.js
generated
vendored
13
node_modules/jsdom/lib/jsdom/level2/style.js
generated
vendored
@@ -2,18 +2,6 @@
|
||||
const cssom = require("cssom");
|
||||
const cssstyle = require("cssstyle");
|
||||
|
||||
// http://dev.w3.org/csswg/cssom/#stylesheetlist
|
||||
// TODO: implement using webidl2js
|
||||
function StyleSheetList() {}
|
||||
|
||||
Object.setPrototypeOf(StyleSheetList.prototype, Array.prototype);
|
||||
|
||||
StyleSheetList.prototype.item = function item(i) {
|
||||
return Object.prototype.hasOwnProperty.call(this, i) ? this[i] : null;
|
||||
};
|
||||
|
||||
exports.StyleSheetList = StyleSheetList;
|
||||
|
||||
exports.addToCore = core => {
|
||||
// What works now:
|
||||
// - Accessing the rules defined in individual stylesheets
|
||||
@@ -40,7 +28,6 @@ exports.addToCore = core => {
|
||||
core.CSSMediaRule = cssom.CSSMediaRule;
|
||||
core.CSSImportRule = cssom.CSSImportRule;
|
||||
core.CSSStyleDeclaration = cssstyle.CSSStyleDeclaration;
|
||||
core.StyleSheetList = StyleSheetList;
|
||||
|
||||
// Relavant specs
|
||||
// http://www.w3.org/TR/DOM-Level-2-Style (2000)
|
||||
|
||||
6
node_modules/jsdom/lib/jsdom/living/aborting/AbortController-impl.js
generated
vendored
6
node_modules/jsdom/lib/jsdom/living/aborting/AbortController-impl.js
generated
vendored
@@ -1,8 +1,10 @@
|
||||
"use strict";
|
||||
|
||||
const AbortSignal = require("../generated/AbortSignal");
|
||||
|
||||
class AbortControllerImpl {
|
||||
constructor(args, privateData) {
|
||||
this.signal = privateData.AbortSignal.createImpl([]);
|
||||
constructor(globalObject) {
|
||||
this.signal = AbortSignal.createImpl(globalObject, []);
|
||||
}
|
||||
|
||||
abort() {
|
||||
|
||||
17
node_modules/jsdom/lib/jsdom/living/aborting/AbortSignal-impl.js
generated
vendored
17
node_modules/jsdom/lib/jsdom/living/aborting/AbortSignal-impl.js
generated
vendored
@@ -1,16 +1,15 @@
|
||||
"use strict";
|
||||
|
||||
const { setupForSimpleEventAccessors } = require("../helpers/create-event-accessor");
|
||||
const { fireAnEvent } = require("../helpers/events");
|
||||
const EventTargetImpl = require("../events/EventTarget-impl").implementation;
|
||||
|
||||
const Event = require("../generated/Event");
|
||||
|
||||
class AbortSignalImpl extends EventTargetImpl {
|
||||
constructor(args, privateData) {
|
||||
super();
|
||||
constructor(globalObject, args, privateData) {
|
||||
super(globalObject, args, privateData);
|
||||
|
||||
// make event firing possible
|
||||
this._ownerDocument = privateData.window.document;
|
||||
this._ownerDocument = globalObject.document;
|
||||
|
||||
this.aborted = false;
|
||||
this.abortAlgorithms = new Set();
|
||||
@@ -27,13 +26,7 @@ class AbortSignalImpl extends EventTargetImpl {
|
||||
}
|
||||
this.abortAlgorithms.clear();
|
||||
|
||||
this._dispatch(Event.createImpl(
|
||||
[
|
||||
"abort",
|
||||
{ bubbles: false, cancelable: false }
|
||||
],
|
||||
{ isTrusted: true }
|
||||
));
|
||||
fireAnEvent("abort", this);
|
||||
}
|
||||
|
||||
_addAlgorithm(algorithm) {
|
||||
|
||||
135
node_modules/jsdom/lib/jsdom/living/attributes.js
generated
vendored
135
node_modules/jsdom/lib/jsdom/living/attributes.js
generated
vendored
@@ -1,12 +1,16 @@
|
||||
"use strict";
|
||||
const DOMException = require("domexception");
|
||||
const attrGenerated = require("./generated/Attr");
|
||||
const { asciiLowercase } = require("./helpers/strings");
|
||||
const DOMException = require("domexception/webidl2js-wrapper");
|
||||
|
||||
const { HTML_NS } = require("./helpers/namespaces");
|
||||
const { asciiLowercase } = require("./helpers/strings");
|
||||
const { queueAttributeMutationRecord } = require("./helpers/mutation-observers");
|
||||
const { enqueueCECallbackReaction } = require("./helpers/custom-elements");
|
||||
|
||||
// The following three are for https://dom.spec.whatwg.org/#concept-element-attribute-has. We don't just have a
|
||||
// predicate tester since removing that kind of flexibility gives us the potential for better future optimizations.
|
||||
|
||||
/* eslint-disable no-restricted-properties */
|
||||
|
||||
exports.hasAttribute = function (element, A) {
|
||||
return element._attributeList.includes(A);
|
||||
};
|
||||
@@ -21,23 +25,43 @@ exports.hasAttributeByNameNS = function (element, namespace, localName) {
|
||||
});
|
||||
};
|
||||
|
||||
exports.changeAttribute = function (element, attribute, value) {
|
||||
// https://dom.spec.whatwg.org/#concept-element-attributes-change
|
||||
// https://dom.spec.whatwg.org/#concept-element-attributes-change
|
||||
exports.changeAttribute = (element, attribute, value) => {
|
||||
const { _localName, _namespace, _value } = attribute;
|
||||
|
||||
queueAttributeMutationRecord(element, _localName, _namespace, _value);
|
||||
|
||||
if (element._ceState === "custom") {
|
||||
enqueueCECallbackReaction(element, "attributeChangedCallback", [
|
||||
_localName,
|
||||
_value,
|
||||
value,
|
||||
_namespace
|
||||
]);
|
||||
}
|
||||
|
||||
const oldValue = attribute._value;
|
||||
attribute._value = value;
|
||||
|
||||
// Run jsdom hooks; roughly correspond to spec's "An attribute is set and an attribute is changed."
|
||||
element._attrModified(attribute._qualifiedName, value, oldValue);
|
||||
element._attrModified(attribute._qualifiedName, value, _value);
|
||||
};
|
||||
|
||||
// https://dom.spec.whatwg.org/#concept-element-attributes-append
|
||||
exports.appendAttribute = function (element, attribute) {
|
||||
// https://dom.spec.whatwg.org/#concept-element-attributes-append
|
||||
const { _localName, _namespace, _value } = attribute;
|
||||
queueAttributeMutationRecord(element, _localName, _namespace, null);
|
||||
|
||||
if (element._ceState === "custom") {
|
||||
enqueueCECallbackReaction(element, "attributeChangedCallback", [
|
||||
_localName,
|
||||
null,
|
||||
_value,
|
||||
_namespace
|
||||
]);
|
||||
}
|
||||
|
||||
const attributeList = element._attributeList;
|
||||
|
||||
// TODO mutation observer stuff
|
||||
|
||||
attributeList.push(attribute);
|
||||
attribute._element = element;
|
||||
|
||||
@@ -52,15 +76,26 @@ exports.appendAttribute = function (element, attribute) {
|
||||
entry.push(attribute);
|
||||
|
||||
// Run jsdom hooks; roughly correspond to spec's "An attribute is set and an attribute is added."
|
||||
element._attrModified(name, attribute._value, null);
|
||||
element._attrModified(name, _value, null);
|
||||
};
|
||||
|
||||
exports.removeAttribute = function (element, attribute) {
|
||||
// https://dom.spec.whatwg.org/#concept-element-attributes-remove
|
||||
|
||||
const attributeList = element._attributeList;
|
||||
const { _localName, _namespace, _value } = attribute;
|
||||
|
||||
// TODO mutation observer stuff
|
||||
queueAttributeMutationRecord(element, _localName, _namespace, _value);
|
||||
|
||||
if (element._ceState === "custom") {
|
||||
enqueueCECallbackReaction(element, "attributeChangedCallback", [
|
||||
_localName,
|
||||
_value,
|
||||
null,
|
||||
_namespace
|
||||
]);
|
||||
}
|
||||
|
||||
const attributeList = element._attributeList;
|
||||
|
||||
for (let i = 0; i < attributeList.length; ++i) {
|
||||
if (attributeList[i] === attribute) {
|
||||
@@ -87,9 +122,20 @@ exports.removeAttribute = function (element, attribute) {
|
||||
exports.replaceAttribute = function (element, oldAttr, newAttr) {
|
||||
// https://dom.spec.whatwg.org/#concept-element-attributes-replace
|
||||
|
||||
const attributeList = element._attributeList;
|
||||
const { _localName, _namespace, _value } = oldAttr;
|
||||
|
||||
// TODO mutation observer stuff
|
||||
queueAttributeMutationRecord(element, _localName, _namespace, _value);
|
||||
|
||||
if (element._ceState === "custom") {
|
||||
enqueueCECallbackReaction(element, "attributeChangedCallback", [
|
||||
_localName,
|
||||
_value,
|
||||
newAttr._value,
|
||||
_namespace
|
||||
]);
|
||||
}
|
||||
|
||||
const attributeList = element._attributeList;
|
||||
|
||||
for (let i = 0; i < attributeList.length; ++i) {
|
||||
if (attributeList[i] === oldAttr) {
|
||||
@@ -176,7 +222,7 @@ exports.setAttribute = function (element, attr) {
|
||||
// https://dom.spec.whatwg.org/#concept-element-attributes-set
|
||||
|
||||
if (attr._element !== null && attr._element !== element) {
|
||||
throw new DOMException("The attribute is in use.", "InUseAttributeError");
|
||||
throw DOMException.create(element._globalObject, ["The attribute is in use.", "InUseAttributeError"]);
|
||||
}
|
||||
|
||||
const oldAttr = exports.getAttributeByNameNS(element, attr._namespace, attr._localName);
|
||||
@@ -205,20 +251,28 @@ exports.setAttributeValue = function (element, localName, value, prefix, namespa
|
||||
|
||||
const attribute = exports.getAttributeByNameNS(element, namespace, localName);
|
||||
if (attribute === null) {
|
||||
const newAttribute = attrGenerated.createImpl([], { namespace, namespacePrefix: prefix, localName, value });
|
||||
const newAttribute = element._ownerDocument._createAttribute({
|
||||
namespace,
|
||||
namespacePrefix: prefix,
|
||||
localName,
|
||||
value
|
||||
});
|
||||
exports.appendAttribute(element, newAttribute);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
exports.changeAttribute(element, attribute, value);
|
||||
};
|
||||
|
||||
// https://dom.spec.whatwg.org/#set-an-existing-attribute-value
|
||||
exports.setAnExistingAttributeValue = (attribute, value) => {
|
||||
if (attribute._element === null) {
|
||||
const element = attribute._element;
|
||||
if (element === null) {
|
||||
attribute._value = value;
|
||||
} else {
|
||||
exports.changeAttribute(element, attribute, value);
|
||||
}
|
||||
|
||||
exports.changeAttribute(attribute._element, attribute, value);
|
||||
};
|
||||
|
||||
exports.removeAttributeByName = function (element, name) {
|
||||
@@ -245,47 +299,6 @@ exports.removeAttributeByNameNS = function (element, namespace, localName) {
|
||||
return attr;
|
||||
};
|
||||
|
||||
exports.copyAttributeList = function (sourceElement, destElement) {
|
||||
// Needed by https://dom.spec.whatwg.org/#concept-node-clone
|
||||
|
||||
for (const sourceAttr of sourceElement._attributeList) {
|
||||
const destAttr = attrGenerated.createImpl([], {
|
||||
namespace: sourceAttr._namespace,
|
||||
namespacePrefix: sourceAttr._namespacePrefix,
|
||||
localName: sourceAttr._localName,
|
||||
value: sourceAttr._value
|
||||
});
|
||||
|
||||
exports.appendAttribute(destElement, destAttr);
|
||||
}
|
||||
};
|
||||
|
||||
exports.attributeListsEqual = function (elementA, elementB) {
|
||||
// Needed by https://dom.spec.whatwg.org/#concept-node-equals
|
||||
|
||||
const listA = elementA._attributeList;
|
||||
const listB = elementB._attributeList;
|
||||
|
||||
if (listA.length !== listB.length) {
|
||||
return false;
|
||||
}
|
||||
|
||||
for (let i = 0; i < listA.length; ++i) {
|
||||
const attrA = listA[i];
|
||||
|
||||
if (!listB.some(attrB => equalsA(attrB))) {
|
||||
return false;
|
||||
}
|
||||
|
||||
function equalsA(attrB) {
|
||||
return attrA._namespace === attrB._namespace && attrA._localName === attrB._localName &&
|
||||
attrA._value === attrB._value;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
};
|
||||
|
||||
exports.attributeNames = function (element) {
|
||||
// Needed by https://dom.spec.whatwg.org/#dom-element-getattributenames
|
||||
|
||||
|
||||
35
node_modules/jsdom/lib/jsdom/living/attributes/Attr-impl.js
generated
vendored
35
node_modules/jsdom/lib/jsdom/living/attributes/Attr-impl.js
generated
vendored
@@ -1,15 +1,20 @@
|
||||
"use strict";
|
||||
|
||||
const attributes = require("../attributes.js");
|
||||
const { setAnExistingAttributeValue } = require("../attributes.js");
|
||||
const NodeImpl = require("../nodes/Node-impl.js").implementation;
|
||||
const { ATTRIBUTE_NODE } = require("../node-type.js");
|
||||
|
||||
exports.implementation = class AttrImpl extends NodeImpl {
|
||||
constructor(globalObject, args, privateData) {
|
||||
super(globalObject, args, privateData);
|
||||
|
||||
exports.implementation = class AttrImpl {
|
||||
constructor(_, privateData) {
|
||||
this._namespace = privateData.namespace !== undefined ? privateData.namespace : null;
|
||||
this._namespacePrefix = privateData.namespacePrefix !== undefined ? privateData.namespacePrefix : null;
|
||||
this._localName = privateData.localName;
|
||||
this._value = privateData.value !== undefined ? privateData.value : "";
|
||||
this._element = privateData.element !== undefined ? privateData.element : null;
|
||||
|
||||
this.nodeType = ATTRIBUTE_NODE;
|
||||
this.specified = true;
|
||||
}
|
||||
|
||||
@@ -36,28 +41,8 @@ exports.implementation = class AttrImpl {
|
||||
get value() {
|
||||
return this._value;
|
||||
}
|
||||
set value(v) {
|
||||
if (this._element === null) {
|
||||
this._value = v;
|
||||
} else {
|
||||
attributes.changeAttribute(this._element, this, v);
|
||||
}
|
||||
}
|
||||
|
||||
// Delegate to value
|
||||
get nodeValue() {
|
||||
return this.value;
|
||||
}
|
||||
set nodeValue(v) {
|
||||
this.value = v;
|
||||
}
|
||||
|
||||
// Delegate to value
|
||||
get textContent() {
|
||||
return this.value;
|
||||
}
|
||||
set textContent(v) {
|
||||
this.value = v;
|
||||
set value(value) {
|
||||
setAnExistingAttributeValue(this, value);
|
||||
}
|
||||
|
||||
get ownerElement() {
|
||||
|
||||
18
node_modules/jsdom/lib/jsdom/living/attributes/NamedNodeMap-impl.js
generated
vendored
18
node_modules/jsdom/lib/jsdom/living/attributes/NamedNodeMap-impl.js
generated
vendored
@@ -1,13 +1,15 @@
|
||||
"use strict";
|
||||
|
||||
const DOMException = require("domexception");
|
||||
const DOMException = require("domexception/webidl2js-wrapper");
|
||||
const idlUtils = require("../generated/utils.js");
|
||||
const attributes = require("../attributes.js");
|
||||
const { HTML_NS } = require("../helpers/namespaces");
|
||||
|
||||
exports.implementation = class NamedNodeMapImpl {
|
||||
constructor(args, privateData) {
|
||||
constructor(globalObject, args, privateData) {
|
||||
this._element = privateData.element;
|
||||
|
||||
this._globalObject = globalObject;
|
||||
}
|
||||
get _attributeList() {
|
||||
return this._element._attributeList;
|
||||
@@ -46,22 +48,30 @@ exports.implementation = class NamedNodeMapImpl {
|
||||
return attributes.getAttributeByNameNS(this._element, namespace, localName);
|
||||
}
|
||||
setNamedItem(attr) {
|
||||
// eslint-disable-next-line no-restricted-properties
|
||||
return attributes.setAttribute(this._element, attr);
|
||||
}
|
||||
setNamedItemNS(attr) {
|
||||
// eslint-disable-next-line no-restricted-properties
|
||||
return attributes.setAttribute(this._element, attr);
|
||||
}
|
||||
removeNamedItem(qualifiedName) {
|
||||
const attr = attributes.removeAttributeByName(this._element, qualifiedName);
|
||||
if (attr === null) {
|
||||
throw new DOMException("Tried to remove an attribute that was not present", "NotFoundError");
|
||||
throw DOMException.create(this._globalObject, [
|
||||
"Tried to remove an attribute that was not present",
|
||||
"NotFoundError"
|
||||
]);
|
||||
}
|
||||
return attr;
|
||||
}
|
||||
removeNamedItemNS(namespace, localName) {
|
||||
const attr = attributes.removeAttributeByNameNS(this._element, namespace, localName);
|
||||
if (attr === null) {
|
||||
throw new DOMException("Tried to remove an attribute that was not present", "NotFoundError");
|
||||
throw DOMException.create(this._globalObject, [
|
||||
"Tried to remove an attribute that was not present",
|
||||
"NotFoundError"
|
||||
]);
|
||||
}
|
||||
return attr;
|
||||
}
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
"use strict";
|
||||
|
||||
const ValidityState = require("../generated/ValidityState");
|
||||
const Event = require("../generated/Event");
|
||||
const { isDisabled } = require("../helpers/form-controls");
|
||||
const { closest } = require("../helpers/traversal");
|
||||
const { fireAnEvent } = require("../helpers/events");
|
||||
|
||||
exports.implementation = class DefaultConstraintValidationImpl {
|
||||
// https://html.spec.whatwg.org/multipage/form-control-infrastructure.html#dom-cva-willvalidate
|
||||
@@ -13,7 +13,9 @@ exports.implementation = class DefaultConstraintValidationImpl {
|
||||
|
||||
get validity() {
|
||||
if (!this._validity) {
|
||||
this._validity = ValidityState.createImpl(this);
|
||||
this._validity = ValidityState.createImpl(this._globalObject, [], {
|
||||
element: this
|
||||
});
|
||||
}
|
||||
return this._validity;
|
||||
}
|
||||
@@ -26,7 +28,7 @@ exports.implementation = class DefaultConstraintValidationImpl {
|
||||
if (this._satisfiesConstraints()) {
|
||||
return true;
|
||||
}
|
||||
this.dispatchEvent(Event.createImpl(["invalid", { cancelable: true }]));
|
||||
fireAnEvent("invalid", this, undefined, { cancelable: true });
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
6
node_modules/jsdom/lib/jsdom/living/constraint-validation/ValidityState-impl.js
generated
vendored
6
node_modules/jsdom/lib/jsdom/living/constraint-validation/ValidityState-impl.js
generated
vendored
@@ -1,7 +1,9 @@
|
||||
"use strict";
|
||||
|
||||
exports.implementation = class ValidityStateImpl {
|
||||
constructor(element, state = {}) {
|
||||
constructor(globalObject, args, privateData) {
|
||||
const { element, state = {} } = privateData;
|
||||
|
||||
this._element = element;
|
||||
this._state = state;
|
||||
}
|
||||
@@ -50,7 +52,7 @@ exports.implementation = class ValidityStateImpl {
|
||||
_failsConstraint(method) {
|
||||
const validationMethod = this._state[method];
|
||||
if (validationMethod) {
|
||||
return this._element.willValidate && validationMethod();
|
||||
return validationMethod();
|
||||
}
|
||||
|
||||
return false;
|
||||
|
||||
38
node_modules/jsdom/lib/jsdom/living/cssom/StyleSheetList-impl.js
generated
vendored
Normal file
38
node_modules/jsdom/lib/jsdom/living/cssom/StyleSheetList-impl.js
generated
vendored
Normal file
@@ -0,0 +1,38 @@
|
||||
"use strict";
|
||||
|
||||
const idlUtils = require("../generated/utils.js");
|
||||
|
||||
exports.implementation = class StyleSheetList {
|
||||
constructor() {
|
||||
this._list = [];
|
||||
}
|
||||
|
||||
get length() {
|
||||
return this._list.length;
|
||||
}
|
||||
|
||||
item(index) {
|
||||
const result = this._list[index];
|
||||
return result !== undefined ? result : null;
|
||||
}
|
||||
|
||||
get [idlUtils.supportedPropertyIndices]() {
|
||||
return this._list.keys();
|
||||
}
|
||||
|
||||
_add(sheet) {
|
||||
const { _list } = this;
|
||||
if (!_list.includes(sheet)) {
|
||||
_list.push(sheet);
|
||||
}
|
||||
}
|
||||
|
||||
_remove(sheet) {
|
||||
const { _list } = this;
|
||||
|
||||
const index = _list.indexOf(sheet);
|
||||
if (index >= 0) {
|
||||
_list.splice(index, 1);
|
||||
}
|
||||
}
|
||||
};
|
||||
260
node_modules/jsdom/lib/jsdom/living/custom-elements/CustomElementRegistry-impl.js
generated
vendored
Normal file
260
node_modules/jsdom/lib/jsdom/living/custom-elements/CustomElementRegistry-impl.js
generated
vendored
Normal file
@@ -0,0 +1,260 @@
|
||||
"use strict";
|
||||
|
||||
const webIDLConversions = require("webidl-conversions");
|
||||
const DOMException = require("domexception/webidl2js-wrapper");
|
||||
|
||||
const NODE_TYPE = require("../node-type");
|
||||
|
||||
const { HTML_NS } = require("../helpers/namespaces");
|
||||
const { getHTMLElementInterface } = require("../helpers/create-element");
|
||||
const { shadowIncludingInclusiveDescendantsIterator } = require("../helpers/shadow-dom");
|
||||
const { isValidCustomElementName, tryUpgradeElement, enqueueCEUpgradeReaction } = require("../helpers/custom-elements");
|
||||
|
||||
const idlUtils = require("../generated/utils");
|
||||
const HTMLUnknownElement = require("../generated/HTMLUnknownElement");
|
||||
|
||||
const LIFECYCLE_CALLBACKS = [
|
||||
"connectedCallback",
|
||||
"disconnectedCallback",
|
||||
"adoptedCallback",
|
||||
"attributeChangedCallback"
|
||||
];
|
||||
|
||||
function convertToSequenceDOMString(obj) {
|
||||
if (!obj || !obj[Symbol.iterator]) {
|
||||
throw new TypeError("Invalid Sequence");
|
||||
}
|
||||
|
||||
return Array.from(obj).map(webIDLConversions.DOMString);
|
||||
}
|
||||
|
||||
// Returns true is the passed value is a valid constructor.
|
||||
// Borrowed from: https://stackoverflow.com/a/39336206/3832710
|
||||
function isConstructor(value) {
|
||||
if (typeof value !== "function") {
|
||||
return false;
|
||||
}
|
||||
|
||||
try {
|
||||
const P = new Proxy(value, {
|
||||
construct() {
|
||||
return {};
|
||||
}
|
||||
});
|
||||
|
||||
// eslint-disable-next-line no-new
|
||||
new P();
|
||||
|
||||
return true;
|
||||
} catch {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
// https://html.spec.whatwg.org/#customelementregistry
|
||||
class CustomElementRegistryImpl {
|
||||
constructor(globalObject) {
|
||||
this._customElementDefinitions = [];
|
||||
this._elementDefinitionIsRunning = false;
|
||||
this._whenDefinedPromiseMap = Object.create(null);
|
||||
|
||||
this._globalObject = globalObject;
|
||||
}
|
||||
|
||||
// https://html.spec.whatwg.org/#dom-customelementregistry-define
|
||||
define(name, ctor, options) {
|
||||
const { _globalObject } = this;
|
||||
|
||||
if (!isConstructor(ctor)) {
|
||||
throw new TypeError("Constructor argument is not a constructor.");
|
||||
}
|
||||
|
||||
if (!isValidCustomElementName(name)) {
|
||||
throw DOMException.create(_globalObject, ["Name argument is not a valid custom element name.", "SyntaxError"]);
|
||||
}
|
||||
|
||||
const nameAlreadyRegistered = this._customElementDefinitions.some(entry => entry.name === name);
|
||||
if (nameAlreadyRegistered) {
|
||||
throw DOMException.create(_globalObject, [
|
||||
"This name has already been registered in the registry.",
|
||||
"NotSupportedError"
|
||||
]);
|
||||
}
|
||||
|
||||
const ctorAlreadyRegistered = this._customElementDefinitions.some(entry => entry.ctor === ctor);
|
||||
if (ctorAlreadyRegistered) {
|
||||
throw DOMException.create(_globalObject, [
|
||||
"This constructor has already been registered in the registry.",
|
||||
"NotSupportedError"
|
||||
]);
|
||||
}
|
||||
|
||||
let localName = name;
|
||||
|
||||
let extendsOption = null;
|
||||
if (options !== undefined && options.extends) {
|
||||
extendsOption = options.extends;
|
||||
}
|
||||
|
||||
if (extendsOption !== null) {
|
||||
if (isValidCustomElementName(extendsOption)) {
|
||||
throw DOMException.create(_globalObject, [
|
||||
"Option extends value can't be a valid custom element name.",
|
||||
"NotSupportedError"
|
||||
]);
|
||||
}
|
||||
|
||||
const extendsInterface = getHTMLElementInterface(extendsOption);
|
||||
if (extendsInterface === HTMLUnknownElement) {
|
||||
throw DOMException.create(_globalObject, [
|
||||
`${extendsOption} is an HTMLUnknownElement.`,
|
||||
"NotSupportedError"
|
||||
]);
|
||||
}
|
||||
|
||||
localName = extendsOption;
|
||||
}
|
||||
|
||||
if (this._elementDefinitionIsRunning) {
|
||||
throw DOMException.create(_globalObject, [
|
||||
"Invalid nested custom element definition.",
|
||||
"NotSupportedError"
|
||||
]);
|
||||
}
|
||||
|
||||
this._elementDefinitionIsRunning = true;
|
||||
|
||||
let disableShadow = false;
|
||||
let observedAttributes = [];
|
||||
const lifecycleCallbacks = {
|
||||
connectedCallback: null,
|
||||
disconnectedCallback: null,
|
||||
adoptedCallback: null,
|
||||
attributeChangedCallback: null
|
||||
};
|
||||
|
||||
let caughtError;
|
||||
try {
|
||||
const { prototype } = ctor;
|
||||
|
||||
if (typeof prototype !== "object") {
|
||||
throw new TypeError("Invalid constructor prototype.");
|
||||
}
|
||||
|
||||
for (const callbackName of LIFECYCLE_CALLBACKS) {
|
||||
const callbackValue = prototype[callbackName];
|
||||
|
||||
if (callbackValue !== undefined) {
|
||||
lifecycleCallbacks[callbackName] = webIDLConversions.Function(callbackValue);
|
||||
}
|
||||
}
|
||||
|
||||
if (lifecycleCallbacks.attributeChangedCallback !== null) {
|
||||
const observedAttributesIterable = ctor.observedAttributes;
|
||||
|
||||
if (observedAttributesIterable !== undefined) {
|
||||
observedAttributes = convertToSequenceDOMString(observedAttributesIterable);
|
||||
}
|
||||
}
|
||||
|
||||
let disabledFeatures = [];
|
||||
const disabledFeaturesIterable = ctor.disabledFeatures;
|
||||
if (disabledFeaturesIterable) {
|
||||
disabledFeatures = convertToSequenceDOMString(disabledFeaturesIterable);
|
||||
}
|
||||
|
||||
disableShadow = disabledFeatures.includes("shadow");
|
||||
} catch (err) {
|
||||
caughtError = err;
|
||||
} finally {
|
||||
this._elementDefinitionIsRunning = false;
|
||||
}
|
||||
|
||||
if (caughtError !== undefined) {
|
||||
throw caughtError;
|
||||
}
|
||||
|
||||
const definition = {
|
||||
name,
|
||||
localName,
|
||||
ctor,
|
||||
observedAttributes,
|
||||
lifecycleCallbacks,
|
||||
disableShadow,
|
||||
constructionStack: []
|
||||
};
|
||||
|
||||
this._customElementDefinitions.push(definition);
|
||||
|
||||
const document = idlUtils.implForWrapper(this._globalObject._document);
|
||||
|
||||
const upgradeCandidates = [];
|
||||
for (const candidate of shadowIncludingInclusiveDescendantsIterator(document)) {
|
||||
if (
|
||||
(candidate._namespaceURI === HTML_NS && candidate._localName === localName) &&
|
||||
(extendsOption === null || candidate._isValue === name)
|
||||
) {
|
||||
upgradeCandidates.push(candidate);
|
||||
}
|
||||
}
|
||||
|
||||
for (const upgradeCandidate of upgradeCandidates) {
|
||||
enqueueCEUpgradeReaction(upgradeCandidate, definition);
|
||||
}
|
||||
|
||||
if (this._whenDefinedPromiseMap[name] !== undefined) {
|
||||
this._whenDefinedPromiseMap[name].resolve(undefined);
|
||||
delete this._whenDefinedPromiseMap[name];
|
||||
}
|
||||
}
|
||||
|
||||
// https://html.spec.whatwg.org/#dom-customelementregistry-get
|
||||
get(name) {
|
||||
const definition = this._customElementDefinitions.find(entry => entry.name === name);
|
||||
return definition && definition.ctor;
|
||||
}
|
||||
|
||||
// https://html.spec.whatwg.org/#dom-customelementregistry-whendefined
|
||||
whenDefined(name) {
|
||||
if (!isValidCustomElementName(name)) {
|
||||
return Promise.reject(DOMException.create(
|
||||
this._globalObject,
|
||||
["Name argument is not a valid custom element name.", "SyntaxError"]
|
||||
));
|
||||
}
|
||||
|
||||
const alreadyRegistered = this._customElementDefinitions.some(entry => entry.name === name);
|
||||
if (alreadyRegistered) {
|
||||
return Promise.resolve();
|
||||
}
|
||||
|
||||
if (this._whenDefinedPromiseMap[name] === undefined) {
|
||||
let resolve;
|
||||
const promise = new Promise(r => {
|
||||
resolve = r;
|
||||
});
|
||||
|
||||
// Store the pending Promise along with the extracted resolve callback to actually resolve the returned Promise,
|
||||
// once the custom element is registered.
|
||||
this._whenDefinedPromiseMap[name] = {
|
||||
promise,
|
||||
resolve
|
||||
};
|
||||
}
|
||||
|
||||
return this._whenDefinedPromiseMap[name].promise;
|
||||
}
|
||||
|
||||
// https://html.spec.whatwg.org/#dom-customelementregistry-upgrade
|
||||
upgrade(root) {
|
||||
for (const candidate of shadowIncludingInclusiveDescendantsIterator(root)) {
|
||||
if (candidate.nodeType === NODE_TYPE.ELEMENT_NODE) {
|
||||
tryUpgradeElement(candidate);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
implementation: CustomElementRegistryImpl
|
||||
};
|
||||
15
node_modules/jsdom/lib/jsdom/living/documents.js
generated
vendored
Normal file
15
node_modules/jsdom/lib/jsdom/living/documents.js
generated
vendored
Normal file
@@ -0,0 +1,15 @@
|
||||
"use strict";
|
||||
const XMLDocument = require("../living/generated/XMLDocument.js");
|
||||
const Document = require("../living/generated/Document.js");
|
||||
const { wrapperForImpl } = require("./generated/utils.js");
|
||||
|
||||
exports.createImpl = (globalObject, options, { alwaysUseDocumentClass = false } = {}) => {
|
||||
if (options.parsingMode === "xml" && !alwaysUseDocumentClass) {
|
||||
return XMLDocument.createImpl(globalObject, [], { options });
|
||||
}
|
||||
return Document.createImpl(globalObject, [], { options });
|
||||
};
|
||||
|
||||
exports.createWrapper = (...args) => {
|
||||
return wrapperForImpl(exports.createImpl(...args));
|
||||
};
|
||||
51
node_modules/jsdom/lib/jsdom/living/domparsing/DOMParser-impl.js
generated
vendored
51
node_modules/jsdom/lib/jsdom/living/domparsing/DOMParser-impl.js
generated
vendored
@@ -1,23 +1,28 @@
|
||||
"use strict";
|
||||
|
||||
const { parseIntoDocument } = require("../../browser/parser");
|
||||
|
||||
const Document = require("../generated/Document");
|
||||
const { applyDocumentFeatures } = require("../../browser/documentfeatures");
|
||||
|
||||
exports.implementation = class DOMParserImpl {
|
||||
constructor(globalObject) {
|
||||
this._globalObject = globalObject;
|
||||
}
|
||||
|
||||
parseFromString(string, contentType) {
|
||||
switch (String(contentType)) {
|
||||
case "text/html": {
|
||||
return createScriptingDisabledDocument("html", contentType, string);
|
||||
return this.createScriptingDisabledDocument("html", contentType, string);
|
||||
}
|
||||
|
||||
case "text/xml":
|
||||
case "application/xml":
|
||||
case "application/xhtml+xml":
|
||||
case "image/svg+xml": {
|
||||
// TODO: use a strict XML parser (sax's strict mode might work?) and create parsererror elements
|
||||
try {
|
||||
return createScriptingDisabledDocument("xml", contentType, string);
|
||||
return this.createScriptingDisabledDocument("xml", contentType, string);
|
||||
} catch (error) {
|
||||
const document = createScriptingDisabledDocument("xml", contentType);
|
||||
const document = this.createScriptingDisabledDocument("xml", contentType);
|
||||
const element = document.createElementNS("http://www.mozilla.org/newlayout/xml/parsererror.xml", "parsererror");
|
||||
|
||||
element.textContent = error.message;
|
||||
@@ -31,27 +36,23 @@ exports.implementation = class DOMParserImpl {
|
||||
throw new TypeError("Invalid contentType");
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
function createScriptingDisabledDocument(parsingMode, contentType, string) {
|
||||
const document = Document.createImpl([], {
|
||||
options: {
|
||||
parsingMode,
|
||||
encoding: "UTF-8",
|
||||
contentType
|
||||
// TODO: somehow set URL to active document's URL
|
||||
createScriptingDisabledDocument(parsingMode, contentType, string) {
|
||||
const document = Document.createImpl(this._globalObject, [], {
|
||||
options: {
|
||||
parsingMode,
|
||||
encoding: "UTF-8",
|
||||
contentType,
|
||||
readyState: "complete",
|
||||
scriptingDisabled: true
|
||||
// TODO: somehow set URL to active document's URL
|
||||
}
|
||||
});
|
||||
|
||||
if (string !== undefined) {
|
||||
parseIntoDocument(string, document);
|
||||
}
|
||||
});
|
||||
|
||||
// "scripting enabled" set to false
|
||||
applyDocumentFeatures(document, {
|
||||
FetchExternalResources: [],
|
||||
SkipExternalResources: false
|
||||
});
|
||||
|
||||
if (string !== undefined) {
|
||||
document._htmlToDom.appendToDocument(string, document);
|
||||
return document;
|
||||
}
|
||||
document.close();
|
||||
return document;
|
||||
}
|
||||
};
|
||||
|
||||
18
node_modules/jsdom/lib/jsdom/living/domparsing/XMLSerializer-impl.js
generated
vendored
Normal file
18
node_modules/jsdom/lib/jsdom/living/domparsing/XMLSerializer-impl.js
generated
vendored
Normal file
@@ -0,0 +1,18 @@
|
||||
"use strict";
|
||||
const serialize = require("w3c-xmlserializer");
|
||||
const DOMException = require("domexception/webidl2js-wrapper");
|
||||
const utils = require("../generated/utils");
|
||||
|
||||
exports.implementation = class XMLSerializerImpl {
|
||||
constructor(globalObject) {
|
||||
this._globalObject = globalObject;
|
||||
}
|
||||
|
||||
serializeToString(root) {
|
||||
try {
|
||||
return serialize(utils.wrapperForImpl(root), { requireWellFormed: false });
|
||||
} catch (e) {
|
||||
throw DOMException.create(this._globalObject, [e.message, "InvalidStateError"]);
|
||||
}
|
||||
}
|
||||
};
|
||||
@@ -1,7 +1,6 @@
|
||||
"use strict";
|
||||
const idlUtils = require("../living/generated/utils");
|
||||
const nodeTypes = require("../living/node-type");
|
||||
const { domSymbolTree } = require("../living/helpers/internal-constants");
|
||||
const nodeTypes = require("../node-type");
|
||||
const { domSymbolTree } = require("../helpers/internal-constants");
|
||||
// Serialization only requires a subset of the tree adapter interface.
|
||||
|
||||
// Tree traversing
|
||||
@@ -11,7 +10,20 @@ exports.getChildNodes = node => node.childNodesForSerializing || domSymbolTree.c
|
||||
|
||||
exports.getParentNode = node => node.parentNode;
|
||||
|
||||
exports.getAttrList = node => idlUtils.wrapperForImpl(node._attributes);
|
||||
exports.getAttrList = element => {
|
||||
const attributeList = [...element._attributeList];
|
||||
|
||||
if (element._isValue && attributeList.every(attr => attr.name !== "is")) {
|
||||
attributeList.unshift({
|
||||
name: "is",
|
||||
namespace: null,
|
||||
prefix: null,
|
||||
value: element._isValue
|
||||
});
|
||||
}
|
||||
|
||||
return attributeList;
|
||||
};
|
||||
|
||||
// Node data
|
||||
exports.getTagName = element => element._qualifiedName; // https://github.com/inikulin/parse5/issues/231
|
||||
@@ -31,7 +43,6 @@ exports.getTemplateContent = templateElement => templateElement._templateContent
|
||||
exports.getDocumentMode = document => document._mode;
|
||||
|
||||
// Node types
|
||||
|
||||
exports.isTextNode = node => node.nodeType === nodeTypes.TEXT_NODE;
|
||||
|
||||
exports.isCommentNode = node => node.nodeType === nodeTypes.COMMENT_NODE;
|
||||
@@ -39,3 +50,10 @@ exports.isCommentNode = node => node.nodeType === nodeTypes.COMMENT_NODE;
|
||||
exports.isDocumentTypeNode = node => node.nodeType === nodeTypes.DOCUMENT_TYPE_NODE;
|
||||
|
||||
exports.isElementNode = node => node.nodeType === nodeTypes.ELEMENT_NODE;
|
||||
|
||||
// Source code location
|
||||
exports.setNodeSourceCodeLocation = (node, location) => {
|
||||
node.sourceCodeLocation = location;
|
||||
};
|
||||
|
||||
exports.getNodeSourceCodeLocation = node => node.sourceCodeLocation;
|
||||
45
node_modules/jsdom/lib/jsdom/living/domparsing/serialization.js
generated
vendored
Normal file
45
node_modules/jsdom/lib/jsdom/living/domparsing/serialization.js
generated
vendored
Normal file
@@ -0,0 +1,45 @@
|
||||
"use strict";
|
||||
|
||||
const produceXMLSerialization = require("w3c-xmlserializer");
|
||||
const parse5 = require("parse5");
|
||||
const DOMException = require("domexception/webidl2js-wrapper");
|
||||
|
||||
const utils = require("../generated/utils");
|
||||
const treeAdapter = require("./parse5-adapter-serialization");
|
||||
const NODE_TYPE = require("../node-type");
|
||||
const NAMESPACES = require("../helpers/namespaces");
|
||||
|
||||
function htmlSerialization(node) {
|
||||
if (
|
||||
node.nodeType === NODE_TYPE.ELEMENT_NODE &&
|
||||
node.namespaceURI === NAMESPACES.HTML_NS &&
|
||||
node.tagName === "TEMPLATE"
|
||||
) {
|
||||
node = node.content;
|
||||
}
|
||||
|
||||
return parse5.serialize(node, { treeAdapter });
|
||||
}
|
||||
|
||||
module.exports.fragmentSerialization = (node, { requireWellFormed, globalObject }) => {
|
||||
const contextDocument =
|
||||
node.nodeType === NODE_TYPE.DOCUMENT_NODE ? node : node._ownerDocument;
|
||||
if (contextDocument._parsingMode === "html") {
|
||||
return htmlSerialization(node);
|
||||
}
|
||||
|
||||
const childNodes = node.childNodesForSerializing || node.childNodes;
|
||||
|
||||
try {
|
||||
let serialized = "";
|
||||
for (let i = 0; i < childNodes.length; ++i) {
|
||||
serialized += produceXMLSerialization(
|
||||
utils.wrapperForImpl(childNodes[i] || childNodes.item(i)),
|
||||
{ requireWellFormed }
|
||||
);
|
||||
}
|
||||
return serialized;
|
||||
} catch (e) {
|
||||
throw DOMException.create(globalObject, [e.message, "InvalidStateError"]);
|
||||
}
|
||||
};
|
||||
100
node_modules/jsdom/lib/jsdom/living/events/Event-impl.js
generated
vendored
100
node_modules/jsdom/lib/jsdom/living/events/Event-impl.js
generated
vendored
@@ -1,9 +1,10 @@
|
||||
"use strict";
|
||||
|
||||
const idlUtils = require("../generated/utils");
|
||||
const EventInit = require("../generated/EventInit");
|
||||
|
||||
class EventImpl {
|
||||
constructor(args, privateData) {
|
||||
constructor(globalObject, args, privateData) {
|
||||
const [type, eventInitDict = this.constructor.defaultInit] = args;
|
||||
|
||||
this.type = type;
|
||||
@@ -25,16 +26,26 @@ class EventImpl {
|
||||
this.currentTarget = null;
|
||||
this.eventPhase = 0;
|
||||
|
||||
this._globalObject = globalObject;
|
||||
this._initializedFlag = true;
|
||||
this._stopPropagationFlag = false;
|
||||
this._stopImmediatePropagationFlag = false;
|
||||
this._canceledFlag = false;
|
||||
this._inPassiveListenerFlag = false;
|
||||
this._dispatchFlag = false;
|
||||
this._path = [];
|
||||
|
||||
this.isTrusted = privateData.isTrusted || false;
|
||||
this.timeStamp = Date.now();
|
||||
}
|
||||
|
||||
// https://dom.spec.whatwg.org/#set-the-canceled-flag
|
||||
_setTheCanceledFlag() {
|
||||
if (this.cancelable && !this._inPassiveListenerFlag) {
|
||||
this._canceledFlag = true;
|
||||
}
|
||||
}
|
||||
|
||||
get srcElement() {
|
||||
return this.target;
|
||||
}
|
||||
@@ -44,8 +55,8 @@ class EventImpl {
|
||||
}
|
||||
|
||||
set returnValue(v) {
|
||||
if (this.cancelable && v === false) {
|
||||
this._canceledFlag = true;
|
||||
if (v === false) {
|
||||
this._setTheCanceledFlag();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -73,9 +84,88 @@ class EventImpl {
|
||||
}
|
||||
|
||||
preventDefault() {
|
||||
if (this.cancelable) {
|
||||
this._canceledFlag = true;
|
||||
this._setTheCanceledFlag();
|
||||
}
|
||||
|
||||
// https://dom.spec.whatwg.org/#dom-event-composedpath
|
||||
// Current implementation is based of https://whatpr.org/dom/699.html#dom-event-composedpath
|
||||
// due to a bug in composed path implementation https://github.com/whatwg/dom/issues/684
|
||||
composedPath() {
|
||||
const composedPath = [];
|
||||
|
||||
const { currentTarget, _path: path } = this;
|
||||
|
||||
if (path.length === 0) {
|
||||
return composedPath;
|
||||
}
|
||||
|
||||
composedPath.push(currentTarget);
|
||||
|
||||
let currentTargetIndex = 0;
|
||||
let currentTargetHiddenSubtreeLevel = 0;
|
||||
|
||||
for (let index = path.length - 1; index >= 0; index--) {
|
||||
const { item, rootOfClosedTree, slotInClosedTree } = path[index];
|
||||
|
||||
if (rootOfClosedTree) {
|
||||
currentTargetHiddenSubtreeLevel++;
|
||||
}
|
||||
|
||||
if (item === idlUtils.implForWrapper(currentTarget)) {
|
||||
currentTargetIndex = index;
|
||||
break;
|
||||
}
|
||||
|
||||
if (slotInClosedTree) {
|
||||
currentTargetHiddenSubtreeLevel--;
|
||||
}
|
||||
}
|
||||
|
||||
let currentHiddenLevel = currentTargetHiddenSubtreeLevel;
|
||||
let maxHiddenLevel = currentTargetHiddenSubtreeLevel;
|
||||
|
||||
for (let i = currentTargetIndex - 1; i >= 0; i--) {
|
||||
const { item, rootOfClosedTree, slotInClosedTree } = path[i];
|
||||
|
||||
if (rootOfClosedTree) {
|
||||
currentHiddenLevel++;
|
||||
}
|
||||
|
||||
if (currentHiddenLevel <= maxHiddenLevel) {
|
||||
composedPath.unshift(idlUtils.wrapperForImpl(item));
|
||||
}
|
||||
|
||||
if (slotInClosedTree) {
|
||||
currentHiddenLevel--;
|
||||
if (currentHiddenLevel < maxHiddenLevel) {
|
||||
maxHiddenLevel = currentHiddenLevel;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
currentHiddenLevel = currentTargetHiddenSubtreeLevel;
|
||||
maxHiddenLevel = currentTargetHiddenSubtreeLevel;
|
||||
|
||||
for (let index = currentTargetIndex + 1; index < path.length; index++) {
|
||||
const { item, rootOfClosedTree, slotInClosedTree } = path[index];
|
||||
|
||||
if (slotInClosedTree) {
|
||||
currentHiddenLevel++;
|
||||
}
|
||||
|
||||
if (currentHiddenLevel <= maxHiddenLevel) {
|
||||
composedPath.push(idlUtils.wrapperForImpl(item));
|
||||
}
|
||||
|
||||
if (rootOfClosedTree) {
|
||||
currentHiddenLevel--;
|
||||
if (currentHiddenLevel < maxHiddenLevel) {
|
||||
maxHiddenLevel = currentHiddenLevel;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return composedPath;
|
||||
}
|
||||
|
||||
_initialize(type, bubbles, cancelable) {
|
||||
|
||||
344
node_modules/jsdom/lib/jsdom/living/events/EventTarget-impl.js
generated
vendored
344
node_modules/jsdom/lib/jsdom/living/events/EventTarget-impl.js
generated
vendored
@@ -1,25 +1,31 @@
|
||||
"use strict";
|
||||
const DOMException = require("domexception");
|
||||
const reportException = require("../helpers/runtime-script-errors");
|
||||
const { domSymbolTree } = require("../helpers/internal-constants");
|
||||
const idlUtils = require("../generated/utils");
|
||||
const DOMException = require("domexception/webidl2js-wrapper");
|
||||
|
||||
const Event = require("../generated/Event").interface;
|
||||
const reportException = require("../helpers/runtime-script-errors");
|
||||
const idlUtils = require("../generated/utils");
|
||||
const { nodeRoot } = require("../helpers/node");
|
||||
const {
|
||||
isNode, isShadowRoot, isSlotable, getEventTargetParent,
|
||||
isShadowInclusiveAncestor, retarget
|
||||
} = require("../helpers/shadow-dom");
|
||||
|
||||
const MouseEvent = require("../generated/MouseEvent");
|
||||
|
||||
const EVENT_PHASE = {
|
||||
NONE: 0,
|
||||
CAPTURING_PHASE: 1,
|
||||
AT_TARGET: 2,
|
||||
BUBBLING_PHASE: 3
|
||||
};
|
||||
|
||||
class EventTargetImpl {
|
||||
constructor() {
|
||||
constructor(globalObject) {
|
||||
this._globalObject = globalObject;
|
||||
this._eventListeners = Object.create(null);
|
||||
}
|
||||
|
||||
addEventListener(type, callback, options) {
|
||||
// webidl2js currently can't handle neither optional arguments nor callback interfaces
|
||||
if (callback === undefined || callback === null) {
|
||||
callback = null;
|
||||
} else if (typeof callback !== "object" && typeof callback !== "function") {
|
||||
throw new TypeError("Only undefined, null, an object, or a function are allowed for the callback parameter");
|
||||
}
|
||||
|
||||
options = normalizeEventHandlerOptions(options, ["capture", "once"]);
|
||||
options = normalizeEventHandlerOptions(options, ["capture", "once", "passive"]);
|
||||
|
||||
if (callback === null) {
|
||||
return;
|
||||
@@ -31,7 +37,10 @@ class EventTargetImpl {
|
||||
|
||||
for (let i = 0; i < this._eventListeners[type].length; ++i) {
|
||||
const listener = this._eventListeners[type][i];
|
||||
if (listener.options.capture === options.capture && listener.callback === callback) {
|
||||
if (
|
||||
listener.callback.objectReference === callback.objectReference &&
|
||||
listener.options.capture === options.capture
|
||||
) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
@@ -43,12 +52,6 @@ class EventTargetImpl {
|
||||
}
|
||||
|
||||
removeEventListener(type, callback, options) {
|
||||
if (callback === undefined || callback === null) {
|
||||
callback = null;
|
||||
} else if (typeof callback !== "object" && typeof callback !== "function") {
|
||||
throw new TypeError("Only undefined, null, an object, or a function are allowed for the callback parameter");
|
||||
}
|
||||
|
||||
options = normalizeEventHandlerOptions(options, ["capture"]);
|
||||
|
||||
if (callback === null) {
|
||||
@@ -62,7 +65,10 @@ class EventTargetImpl {
|
||||
|
||||
for (let i = 0; i < this._eventListeners[type].length; ++i) {
|
||||
const listener = this._eventListeners[type][i];
|
||||
if (listener.callback === callback && listener.options.capture === options.capture) {
|
||||
if (
|
||||
listener.callback.objectReference === callback.objectReference &&
|
||||
listener.options.capture === options.capture
|
||||
) {
|
||||
this._eventListeners[type].splice(i, 1);
|
||||
break;
|
||||
}
|
||||
@@ -71,10 +77,16 @@ class EventTargetImpl {
|
||||
|
||||
dispatchEvent(eventImpl) {
|
||||
if (eventImpl._dispatchFlag || !eventImpl._initializedFlag) {
|
||||
throw new DOMException("Tried to dispatch an uninitialized event", "InvalidStateError");
|
||||
throw DOMException.create(this._globalObject, [
|
||||
"Tried to dispatch an uninitialized event",
|
||||
"InvalidStateError"
|
||||
]);
|
||||
}
|
||||
if (eventImpl.eventPhase !== Event.NONE) {
|
||||
throw new DOMException("Tried to dispatch a dispatching event", "InvalidStateError");
|
||||
if (eventImpl.eventPhase !== EVENT_PHASE.NONE) {
|
||||
throw DOMException.create(this._globalObject, [
|
||||
"Tried to dispatch a dispatching event",
|
||||
"InvalidStateError"
|
||||
]);
|
||||
}
|
||||
|
||||
eventImpl.isTrusted = false;
|
||||
@@ -82,63 +94,155 @@ class EventTargetImpl {
|
||||
return this._dispatch(eventImpl);
|
||||
}
|
||||
|
||||
_dispatch(eventImpl, targetOverride) {
|
||||
// https://dom.spec.whatwg.org/#get-the-parent
|
||||
_getTheParent() {
|
||||
return null;
|
||||
}
|
||||
|
||||
// https://dom.spec.whatwg.org/#concept-event-dispatch
|
||||
// legacyOutputDidListenersThrowFlag optional parameter is not necessary here since it is only used by indexDB.
|
||||
_dispatch(eventImpl, targetOverride /* , legacyOutputDidListenersThrowFlag */) {
|
||||
let targetImpl = this;
|
||||
let clearTargets = false;
|
||||
let activationTarget = null;
|
||||
|
||||
eventImpl._dispatchFlag = true;
|
||||
eventImpl.target = targetOverride || this;
|
||||
|
||||
const eventPath = [];
|
||||
let { target } = eventImpl;
|
||||
let targetParent = domSymbolTree.parent(target);
|
||||
while (targetParent) {
|
||||
eventPath.push(targetParent);
|
||||
target = targetParent;
|
||||
targetParent = domSymbolTree.parent(targetParent);
|
||||
}
|
||||
if (eventImpl.type !== "load" && target._defaultView) {
|
||||
// https://html.spec.whatwg.org/#events-and-the-window-object
|
||||
eventPath.push(idlUtils.implForWrapper(target._defaultView));
|
||||
}
|
||||
targetOverride = targetOverride || targetImpl;
|
||||
let relatedTarget = retarget(eventImpl.relatedTarget, targetImpl);
|
||||
|
||||
eventImpl.eventPhase = Event.CAPTURING_PHASE;
|
||||
for (let i = eventPath.length - 1; i >= 0; --i) {
|
||||
if (eventImpl._stopPropagationFlag) {
|
||||
break;
|
||||
if (targetImpl !== relatedTarget || targetImpl === eventImpl.relatedTarget) {
|
||||
const touchTargets = [];
|
||||
|
||||
appendToEventPath(eventImpl, targetImpl, targetOverride, relatedTarget, touchTargets, false);
|
||||
|
||||
const isActivationEvent = MouseEvent.isImpl(eventImpl) && eventImpl.type === "click";
|
||||
|
||||
if (isActivationEvent && targetImpl._hasActivationBehavior) {
|
||||
activationTarget = targetImpl;
|
||||
}
|
||||
|
||||
const object = eventPath[i];
|
||||
const objectImpl = idlUtils.implForWrapper(object) || object; // window :(
|
||||
const eventListeners = objectImpl._eventListeners[eventImpl.type];
|
||||
invokeEventListeners(eventListeners, object, eventImpl);
|
||||
}
|
||||
let slotInClosedTree = false;
|
||||
let slotable = isSlotable(targetImpl) && targetImpl._assignedSlot ? targetImpl : null;
|
||||
let parent = getEventTargetParent(targetImpl, eventImpl);
|
||||
|
||||
eventImpl.eventPhase = Event.AT_TARGET;
|
||||
// Populate event path
|
||||
// https://dom.spec.whatwg.org/#event-path
|
||||
while (parent !== null) {
|
||||
if (slotable !== null) {
|
||||
if (parent.localName !== "slot") {
|
||||
throw new Error(`JSDOM Internal Error: Expected parent to be a Slot`);
|
||||
}
|
||||
|
||||
if (!eventImpl._stopPropagationFlag) {
|
||||
if (this._eventListeners[eventImpl.type]) {
|
||||
const eventListeners = this._eventListeners[eventImpl.type];
|
||||
invokeEventListeners(eventListeners, eventImpl.target, eventImpl);
|
||||
}
|
||||
}
|
||||
slotable = null;
|
||||
|
||||
if (eventImpl.bubbles) {
|
||||
eventImpl.eventPhase = Event.BUBBLING_PHASE;
|
||||
for (let i = 0; i < eventPath.length; ++i) {
|
||||
if (eventImpl._stopPropagationFlag) {
|
||||
break;
|
||||
const parentRoot = nodeRoot(parent);
|
||||
if (isShadowRoot(parentRoot) && parentRoot.mode === "closed") {
|
||||
slotInClosedTree = true;
|
||||
}
|
||||
}
|
||||
|
||||
const object = eventPath[i];
|
||||
const objectImpl = idlUtils.implForWrapper(object) || object; // window :(
|
||||
const eventListeners = objectImpl._eventListeners[eventImpl.type];
|
||||
invokeEventListeners(eventListeners, object, eventImpl);
|
||||
if (isSlotable(parent) && parent._assignedSlot) {
|
||||
slotable = parent;
|
||||
}
|
||||
|
||||
relatedTarget = retarget(eventImpl.relatedTarget, parent);
|
||||
|
||||
if (
|
||||
(isNode(parent) && isShadowInclusiveAncestor(nodeRoot(targetImpl), parent)) ||
|
||||
idlUtils.wrapperForImpl(parent).constructor.name === "Window"
|
||||
) {
|
||||
if (isActivationEvent && eventImpl.bubbles && activationTarget === null &&
|
||||
parent._hasActivationBehavior) {
|
||||
activationTarget = parent;
|
||||
}
|
||||
|
||||
appendToEventPath(eventImpl, parent, null, relatedTarget, touchTargets, slotInClosedTree);
|
||||
} else if (parent === relatedTarget) {
|
||||
parent = null;
|
||||
} else {
|
||||
targetImpl = parent;
|
||||
|
||||
if (isActivationEvent && activationTarget === null && targetImpl._hasActivationBehavior) {
|
||||
activationTarget = targetImpl;
|
||||
}
|
||||
|
||||
appendToEventPath(eventImpl, parent, targetImpl, relatedTarget, touchTargets, slotInClosedTree);
|
||||
}
|
||||
|
||||
if (parent !== null) {
|
||||
parent = getEventTargetParent(parent, eventImpl);
|
||||
}
|
||||
|
||||
slotInClosedTree = false;
|
||||
}
|
||||
|
||||
let clearTargetsStructIndex = -1;
|
||||
for (let i = eventImpl._path.length - 1; i >= 0 && clearTargetsStructIndex === -1; i--) {
|
||||
if (eventImpl._path[i].target !== null) {
|
||||
clearTargetsStructIndex = i;
|
||||
}
|
||||
}
|
||||
const clearTargetsStruct = eventImpl._path[clearTargetsStructIndex];
|
||||
|
||||
clearTargets =
|
||||
(isNode(clearTargetsStruct.target) && isShadowRoot(nodeRoot(clearTargetsStruct.target))) ||
|
||||
(isNode(clearTargetsStruct.relatedTarget) && isShadowRoot(nodeRoot(clearTargetsStruct.relatedTarget)));
|
||||
|
||||
if (activationTarget !== null && activationTarget._legacyPreActivationBehavior) {
|
||||
activationTarget._legacyPreActivationBehavior();
|
||||
}
|
||||
|
||||
for (let i = eventImpl._path.length - 1; i >= 0; --i) {
|
||||
const struct = eventImpl._path[i];
|
||||
|
||||
if (struct.target !== null) {
|
||||
eventImpl.eventPhase = EVENT_PHASE.AT_TARGET;
|
||||
} else {
|
||||
eventImpl.eventPhase = EVENT_PHASE.CAPTURING_PHASE;
|
||||
}
|
||||
|
||||
invokeEventListeners(struct, eventImpl, "capturing");
|
||||
}
|
||||
|
||||
for (let i = 0; i < eventImpl._path.length; i++) {
|
||||
const struct = eventImpl._path[i];
|
||||
|
||||
if (struct.target !== null) {
|
||||
eventImpl.eventPhase = EVENT_PHASE.AT_TARGET;
|
||||
} else {
|
||||
if (!eventImpl.bubbles) {
|
||||
continue;
|
||||
}
|
||||
|
||||
eventImpl.eventPhase = EVENT_PHASE.BUBBLING_PHASE;
|
||||
}
|
||||
|
||||
invokeEventListeners(struct, eventImpl, "bubbling");
|
||||
}
|
||||
}
|
||||
|
||||
eventImpl.eventPhase = EVENT_PHASE.NONE;
|
||||
|
||||
eventImpl.currentTarget = null;
|
||||
eventImpl._path = [];
|
||||
eventImpl._dispatchFlag = false;
|
||||
eventImpl._stopPropagationFlag = false;
|
||||
eventImpl._stopImmediatePropagationFlag = false;
|
||||
eventImpl.eventPhase = Event.NONE;
|
||||
eventImpl.currentTarget = null;
|
||||
|
||||
if (clearTargets) {
|
||||
eventImpl.target = null;
|
||||
eventImpl.relatedTarget = null;
|
||||
}
|
||||
|
||||
if (activationTarget !== null) {
|
||||
if (!eventImpl._canceledFlag) {
|
||||
activationTarget._activationBehavior(eventImpl);
|
||||
} else if (activationTarget._legacyCanceledActivationBehavior) {
|
||||
activationTarget._legacyCanceledActivationBehavior();
|
||||
}
|
||||
}
|
||||
|
||||
return !eventImpl._canceledFlag;
|
||||
}
|
||||
}
|
||||
@@ -147,51 +251,71 @@ module.exports = {
|
||||
implementation: EventTargetImpl
|
||||
};
|
||||
|
||||
function invokeEventListeners(listeners, target, eventImpl) {
|
||||
// https://dom.spec.whatwg.org/#concept-event-listener-invoke
|
||||
function invokeEventListeners(struct, eventImpl, phase) {
|
||||
const structIndex = eventImpl._path.indexOf(struct);
|
||||
for (let i = structIndex; i >= 0; i--) {
|
||||
const t = eventImpl._path[i];
|
||||
if (t.target) {
|
||||
eventImpl.target = t.target;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
eventImpl.relatedTarget = idlUtils.wrapperForImpl(struct.relatedTarget);
|
||||
|
||||
if (eventImpl._stopPropagationFlag) {
|
||||
return;
|
||||
}
|
||||
|
||||
eventImpl.currentTarget = idlUtils.wrapperForImpl(struct.item);
|
||||
|
||||
const listeners = struct.item._eventListeners;
|
||||
innerInvokeEventListeners(eventImpl, listeners, phase, struct);
|
||||
}
|
||||
|
||||
// https://dom.spec.whatwg.org/#concept-event-listener-inner-invoke
|
||||
function innerInvokeEventListeners(eventImpl, listeners, phase) {
|
||||
let found = false;
|
||||
|
||||
const { type, target } = eventImpl;
|
||||
const wrapper = idlUtils.wrapperForImpl(target);
|
||||
const document = target._ownerDocument || (wrapper && (wrapper._document || wrapper._ownerDocument));
|
||||
// Will be falsy for windows that have closed
|
||||
if (!document) {
|
||||
return;
|
||||
|
||||
if (!listeners || !listeners[type]) {
|
||||
return found;
|
||||
}
|
||||
|
||||
// workaround for events emitted on window (window-proxy)
|
||||
// the wrapper is the root window instance, but we only want to expose the vm proxy at all times
|
||||
if (wrapper._document && wrapper.constructor.name === "Window") {
|
||||
target = idlUtils.implForWrapper(wrapper._document)._defaultView;
|
||||
}
|
||||
eventImpl.currentTarget = target;
|
||||
if (!listeners) {
|
||||
return;
|
||||
}
|
||||
// Copy event listeners before iterating since the list can be modified during the iteration.
|
||||
const handlers = listeners[type].slice();
|
||||
|
||||
const handlers = listeners.slice();
|
||||
for (let i = 0; i < handlers.length; ++i) {
|
||||
if (eventImpl._stopImmediatePropagationFlag) {
|
||||
return;
|
||||
for (let i = 0; i < handlers.length; i++) {
|
||||
const listener = handlers[i];
|
||||
const { capture, once, passive } = listener.options;
|
||||
|
||||
// Check if the event listener has been removed since the listeners has been cloned.
|
||||
if (!listeners[type].includes(listener)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
const listener = handlers[i];
|
||||
const { capture, once/* , passive */ } = listener.options;
|
||||
found = true;
|
||||
|
||||
if (listeners.indexOf(listener) === -1 ||
|
||||
(eventImpl.eventPhase === Event.CAPTURING_PHASE && !capture) ||
|
||||
(eventImpl.eventPhase === Event.BUBBLING_PHASE && capture)) {
|
||||
if (
|
||||
(phase === "capturing" && !capture) ||
|
||||
(phase === "bubbling" && capture)
|
||||
) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (once) {
|
||||
listeners.splice(listeners.indexOf(listener), 1);
|
||||
listeners[type].splice(listeners[type].indexOf(listener), 1);
|
||||
}
|
||||
|
||||
if (passive) {
|
||||
eventImpl._inPassiveListenerFlag = true;
|
||||
}
|
||||
|
||||
try {
|
||||
if (typeof listener.callback === "object") {
|
||||
if (typeof listener.callback.handleEvent === "function") {
|
||||
listener.callback.handleEvent(idlUtils.wrapperForImpl(eventImpl));
|
||||
}
|
||||
} else {
|
||||
listener.callback.call(idlUtils.wrapperForImpl(eventImpl.currentTarget), idlUtils.wrapperForImpl(eventImpl));
|
||||
}
|
||||
listener.callback.call(eventImpl.currentTarget, eventImpl);
|
||||
} catch (e) {
|
||||
let window = null;
|
||||
if (wrapper && wrapper._document) {
|
||||
@@ -201,7 +325,7 @@ function invokeEventListeners(listeners, target, eventImpl) {
|
||||
// Triggered by most webidl2js'ed instances
|
||||
window = target._ownerDocument._defaultView;
|
||||
} else if (wrapper._ownerDocument) {
|
||||
// Currently triggered by XHR and some other non-webidl2js things
|
||||
// Currently triggered by some non-webidl2js things
|
||||
window = wrapper._ownerDocument._defaultView;
|
||||
}
|
||||
|
||||
@@ -210,7 +334,15 @@ function invokeEventListeners(listeners, target, eventImpl) {
|
||||
}
|
||||
// Errors in window-less documents just get swallowed... can you think of anything better?
|
||||
}
|
||||
|
||||
eventImpl._inPassiveListenerFlag = false;
|
||||
|
||||
if (eventImpl._stopImmediatePropagationFlag) {
|
||||
return found;
|
||||
}
|
||||
}
|
||||
|
||||
return found;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -241,3 +373,19 @@ function normalizeEventHandlerOptions(options, defaultBoolKeys) {
|
||||
|
||||
return returnValue;
|
||||
}
|
||||
|
||||
// https://dom.spec.whatwg.org/#concept-event-path-append
|
||||
function appendToEventPath(eventImpl, target, targetOverride, relatedTarget, touchTargets, slotInClosedTree) {
|
||||
const itemInShadowTree = isNode(target) && isShadowRoot(nodeRoot(target));
|
||||
const rootOfClosedTree = isShadowRoot(target) && target.mode === "closed";
|
||||
|
||||
eventImpl._path.push({
|
||||
item: target,
|
||||
itemInShadowTree,
|
||||
target: targetOverride,
|
||||
relatedTarget,
|
||||
touchTargets,
|
||||
rootOfClosedTree,
|
||||
slotInClosedTree
|
||||
});
|
||||
}
|
||||
|
||||
23
node_modules/jsdom/lib/jsdom/living/events/InputEvent-impl.js
generated
vendored
Normal file
23
node_modules/jsdom/lib/jsdom/living/events/InputEvent-impl.js
generated
vendored
Normal file
@@ -0,0 +1,23 @@
|
||||
"use strict";
|
||||
|
||||
const UIEventImpl = require("./UIEvent-impl").implementation;
|
||||
|
||||
const InputEventInit = require("../generated/InputEventInit");
|
||||
|
||||
// https://w3c.github.io/uievents/#interface-inputevent
|
||||
class InputEventImpl extends UIEventImpl {
|
||||
initInputEvent(type, bubbles, cancelable, data, isComposing) {
|
||||
if (this._dispatchFlag) {
|
||||
return;
|
||||
}
|
||||
|
||||
this.initUIEvent(type, bubbles, cancelable);
|
||||
this.data = data;
|
||||
this.isComposing = isComposing;
|
||||
}
|
||||
}
|
||||
InputEventImpl.defaultInit = InputEventInit.convert(undefined);
|
||||
|
||||
module.exports = {
|
||||
implementation: InputEventImpl
|
||||
};
|
||||
20
node_modules/jsdom/lib/jsdom/living/events/PageTransitionEvent-impl.js
generated
vendored
Normal file
20
node_modules/jsdom/lib/jsdom/living/events/PageTransitionEvent-impl.js
generated
vendored
Normal file
@@ -0,0 +1,20 @@
|
||||
"use strict";
|
||||
|
||||
const EventImpl = require("./Event-impl").implementation;
|
||||
|
||||
const PageTransitionEventInit = require("../generated/PageTransitionEventInit");
|
||||
|
||||
// https://html.spec.whatwg.org/multipage/browsing-the-web.html#pagetransitionevent
|
||||
class PageTransitionEventImpl extends EventImpl {
|
||||
initPageTransitionEvent(type, bubbles, cancelable, persisted) {
|
||||
if (this._dispatchFlag) {
|
||||
return;
|
||||
}
|
||||
|
||||
this.initEvent(type, bubbles, cancelable);
|
||||
this.persisted = persisted;
|
||||
}
|
||||
}
|
||||
PageTransitionEventImpl.defaultInit = PageTransitionEventInit.convert(undefined);
|
||||
|
||||
exports.implementation = PageTransitionEventImpl;
|
||||
4
node_modules/jsdom/lib/jsdom/living/events/UIEvent-impl.js
generated
vendored
4
node_modules/jsdom/lib/jsdom/living/events/UIEvent-impl.js
generated
vendored
@@ -21,7 +21,7 @@ function isWindow(val) {
|
||||
}
|
||||
|
||||
class UIEventImpl extends EventImpl {
|
||||
constructor(args, privateData) {
|
||||
constructor(globalObject, args, privateData) {
|
||||
const eventInitDict = args[1];
|
||||
|
||||
// undefined check included so that we can omit the property in internal usage.
|
||||
@@ -32,7 +32,7 @@ class UIEventImpl extends EventImpl {
|
||||
}
|
||||
}
|
||||
|
||||
super(args, privateData);
|
||||
super(globalObject, args, privateData);
|
||||
}
|
||||
|
||||
initUIEvent(type, bubbles, cancelable, view, detail) {
|
||||
|
||||
165
node_modules/jsdom/lib/jsdom/living/fetch/Headers-impl.js
generated
vendored
Normal file
165
node_modules/jsdom/lib/jsdom/living/fetch/Headers-impl.js
generated
vendored
Normal file
@@ -0,0 +1,165 @@
|
||||
"use strict";
|
||||
|
||||
const {
|
||||
isForbidden,
|
||||
isForbiddenResponse,
|
||||
isPrivilegedNoCORSRequest,
|
||||
isNoCORSSafelistedRequest,
|
||||
isCORSWhitelisted
|
||||
} = require("./header-types");
|
||||
const HeaderList = require("./header-list");
|
||||
|
||||
function assertName(name) {
|
||||
if (!name.match(/^[!#$%&'*+\-.^`|~\w]+$/)) {
|
||||
throw new TypeError("name is invalid");
|
||||
}
|
||||
}
|
||||
|
||||
function assertValue(value) {
|
||||
if (value.match(/[\0\r\n]/)) {
|
||||
throw new TypeError("value is invalid");
|
||||
}
|
||||
}
|
||||
|
||||
class HeadersImpl {
|
||||
constructor(globalObject, args) {
|
||||
this.guard = "none";
|
||||
this.headersList = new HeaderList();
|
||||
|
||||
if (args[0]) {
|
||||
this._fill(args[0]);
|
||||
}
|
||||
}
|
||||
|
||||
_fill(init) {
|
||||
if (Array.isArray(init)) {
|
||||
for (const header of init) {
|
||||
if (header.length !== 2) {
|
||||
throw new TypeError("init is invalid");
|
||||
}
|
||||
this.append(header[0], header[1]);
|
||||
}
|
||||
} else {
|
||||
for (const key of Object.keys(init)) {
|
||||
this.append(key, init[key]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
has(name) {
|
||||
assertName(name);
|
||||
return this.headersList.contains(name);
|
||||
}
|
||||
|
||||
get(name) {
|
||||
assertName(name);
|
||||
return this.headersList.get(name);
|
||||
}
|
||||
|
||||
_removePrivilegedNoCORSHeaders() {
|
||||
this.headersList.delete("range");
|
||||
}
|
||||
|
||||
append(name, value) {
|
||||
value = value.trim();
|
||||
assertName(name);
|
||||
assertValue(value);
|
||||
|
||||
switch (this.guard) {
|
||||
case "immutable":
|
||||
throw new TypeError("Headers is immutable");
|
||||
case "request":
|
||||
if (isForbidden(name)) {
|
||||
return;
|
||||
}
|
||||
break;
|
||||
case "request-no-cors": {
|
||||
let temporaryValue = this.get(name);
|
||||
if (temporaryValue === null) {
|
||||
temporaryValue = value;
|
||||
} else {
|
||||
temporaryValue += `, ${value}`;
|
||||
}
|
||||
if (!isCORSWhitelisted(name, value)) {
|
||||
return;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case "response":
|
||||
if (isForbiddenResponse(name)) {
|
||||
return;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
this.headersList.append(name, value);
|
||||
this._removePrivilegedNoCORSHeaders();
|
||||
}
|
||||
|
||||
set(name, value) {
|
||||
value = value.trim();
|
||||
assertName(name);
|
||||
assertValue(value);
|
||||
|
||||
switch (this.guard) {
|
||||
case "immutable":
|
||||
throw new TypeError("Headers is immutable");
|
||||
case "request":
|
||||
if (isForbidden(name)) {
|
||||
return;
|
||||
}
|
||||
break;
|
||||
case "request-no-cors": {
|
||||
if (!isCORSWhitelisted(name, value)) {
|
||||
return;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case "response":
|
||||
if (isForbiddenResponse(name)) {
|
||||
return;
|
||||
}
|
||||
break;
|
||||
}
|
||||
this.headersList.set(name, value);
|
||||
this._removePrivilegedNoCORSHeaders();
|
||||
}
|
||||
|
||||
delete(name) {
|
||||
assertName(name);
|
||||
|
||||
switch (this.guard) {
|
||||
case "immutable":
|
||||
throw new TypeError("Headers is immutable");
|
||||
case "request":
|
||||
if (isForbidden(name)) {
|
||||
return;
|
||||
}
|
||||
break;
|
||||
case "request-no-cors": {
|
||||
if (
|
||||
!isNoCORSSafelistedRequest(name) &&
|
||||
!isPrivilegedNoCORSRequest(name)
|
||||
) {
|
||||
return;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case "response":
|
||||
if (isForbiddenResponse(name)) {
|
||||
return;
|
||||
}
|
||||
break;
|
||||
}
|
||||
this.headersList.delete(name);
|
||||
this._removePrivilegedNoCORSHeaders();
|
||||
}
|
||||
|
||||
* [Symbol.iterator]() {
|
||||
for (const header of this.headersList.sortAndCombine()) {
|
||||
yield header;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
exports.implementation = HeadersImpl;
|
||||
54
node_modules/jsdom/lib/jsdom/living/fetch/header-list.js
generated
vendored
Normal file
54
node_modules/jsdom/lib/jsdom/living/fetch/header-list.js
generated
vendored
Normal file
@@ -0,0 +1,54 @@
|
||||
"use strict";
|
||||
|
||||
/**
|
||||
* Provides some utility functions for somewhat efficiently modifying a
|
||||
* collection of headers.
|
||||
*
|
||||
* Note that this class only operates on ByteStrings (which is also why we use
|
||||
* toLowerCase internally).
|
||||
*/
|
||||
class HeaderList {
|
||||
constructor() {
|
||||
this.headers = new Map();
|
||||
}
|
||||
|
||||
append(name, value) {
|
||||
const existing = this.headers.get(name.toLowerCase());
|
||||
if (existing) {
|
||||
name = existing[0].name;
|
||||
existing.push({ name, value });
|
||||
} else {
|
||||
this.headers.set(name.toLowerCase(), [{ name, value }]);
|
||||
}
|
||||
}
|
||||
|
||||
contains(name) {
|
||||
return this.headers.has(name.toLowerCase());
|
||||
}
|
||||
|
||||
get(name) {
|
||||
name = name.toLowerCase();
|
||||
const values = this.headers.get(name);
|
||||
if (!values) {
|
||||
return null;
|
||||
}
|
||||
return values.map(h => h.value).join(", ");
|
||||
}
|
||||
|
||||
delete(name) {
|
||||
this.headers.delete(name.toLowerCase());
|
||||
}
|
||||
|
||||
set(name, value) {
|
||||
const lowerName = name.toLowerCase();
|
||||
this.headers.delete(lowerName);
|
||||
this.headers.set(lowerName, [{ name, value }]);
|
||||
}
|
||||
|
||||
sortAndCombine() {
|
||||
const names = [...this.headers.keys()].sort();
|
||||
return names.map(n => [n, this.get(n)]);
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = HeaderList;
|
||||
103
node_modules/jsdom/lib/jsdom/living/fetch/header-types.js
generated
vendored
Normal file
103
node_modules/jsdom/lib/jsdom/living/fetch/header-types.js
generated
vendored
Normal file
@@ -0,0 +1,103 @@
|
||||
"use strict";
|
||||
|
||||
const MIMEType = require("whatwg-mimetype");
|
||||
|
||||
const PRIVILEGED_NO_CORS_REQUEST = new Set(["range"]);
|
||||
function isPrivilegedNoCORSRequest(name) {
|
||||
return PRIVILEGED_NO_CORS_REQUEST.has(name.toLowerCase());
|
||||
}
|
||||
|
||||
const NO_CORS_SAFELISTED_REQUEST = new Set([
|
||||
`accept`,
|
||||
`accept-language`,
|
||||
`content-language`,
|
||||
`content-type`
|
||||
]);
|
||||
function isNoCORSSafelistedRequest(name) {
|
||||
return NO_CORS_SAFELISTED_REQUEST.has(name.toLowerCase());
|
||||
}
|
||||
|
||||
const FORBIDDEN = new Set([
|
||||
`accept-charset`,
|
||||
`accept-encoding`,
|
||||
`access-control-request-headers`,
|
||||
`access-control-request-method`,
|
||||
`connection`,
|
||||
`content-length`,
|
||||
`cookie`,
|
||||
`cookie2`,
|
||||
`date`,
|
||||
`dnt`,
|
||||
`expect`,
|
||||
`host`,
|
||||
`keep-alive`,
|
||||
`origin`,
|
||||
`referer`,
|
||||
`te`,
|
||||
`trailer`,
|
||||
`transfer-encoding`,
|
||||
`upgrade`,
|
||||
`via`
|
||||
]);
|
||||
function isForbidden(name) {
|
||||
name = name.toLowerCase();
|
||||
return (
|
||||
FORBIDDEN.has(name) || name.startsWith("proxy-") || name.startsWith("sec-")
|
||||
);
|
||||
}
|
||||
|
||||
const FORBIDDEN_RESPONSE = new Set(["set-cookie", "set-cookie2"]);
|
||||
function isForbiddenResponse(name) {
|
||||
return FORBIDDEN_RESPONSE.has(name.toLowerCase());
|
||||
}
|
||||
|
||||
const CORS_UNSAFE_BYTE = /[\x00-\x08\x0A-\x1F"():<>?@[\\\]{}\x7F]/;
|
||||
function isCORSWhitelisted(name, value) {
|
||||
name = name.toLowerCase();
|
||||
switch (name) {
|
||||
case "accept":
|
||||
if (value.match(CORS_UNSAFE_BYTE)) {
|
||||
return false;
|
||||
}
|
||||
break;
|
||||
case "accept-language":
|
||||
case "content-language":
|
||||
if (value.match(/[^\x30-\x39\x41-\x5A\x61-\x7A *,\-.;=]/)) {
|
||||
return false;
|
||||
}
|
||||
break;
|
||||
case "content-type": {
|
||||
if (value.match(CORS_UNSAFE_BYTE)) {
|
||||
return false;
|
||||
}
|
||||
const mimeType = MIMEType.parse(value);
|
||||
if (mimeType === null) {
|
||||
return false;
|
||||
}
|
||||
if (
|
||||
![
|
||||
"application/x-www-form-urlencoded",
|
||||
"multipart/form-data",
|
||||
"text/plain"
|
||||
].includes(mimeType.essence)
|
||||
) {
|
||||
return false;
|
||||
}
|
||||
break;
|
||||
}
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
if (Buffer.from(value).length > 128) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
isPrivilegedNoCORSRequest,
|
||||
isNoCORSSafelistedRequest,
|
||||
isForbidden,
|
||||
isForbiddenResponse,
|
||||
isCORSWhitelisted
|
||||
};
|
||||
13
node_modules/jsdom/lib/jsdom/living/file-api/Blob-impl.js
generated
vendored
13
node_modules/jsdom/lib/jsdom/living/file-api/Blob-impl.js
generated
vendored
@@ -1,13 +1,15 @@
|
||||
"use strict";
|
||||
const { EOL } = require("os");
|
||||
const Blob = require("../generated/Blob");
|
||||
const { isArrayBuffer } = require("../generated/utils");
|
||||
|
||||
function convertLineEndingsToNative(s) {
|
||||
return s.replace(/\r\n|\r|\n/g, EOL);
|
||||
// jsdom always pretends to be *nix, for consistency.
|
||||
// See also https://github.com/jsdom/jsdom/issues/2396.
|
||||
return s.replace(/\r\n|\r|\n/g, "\n");
|
||||
}
|
||||
|
||||
exports.implementation = class BlobImpl {
|
||||
constructor(args) {
|
||||
constructor(globalObject, args) {
|
||||
const parts = args[0];
|
||||
const properties = args[1];
|
||||
|
||||
@@ -16,7 +18,7 @@ exports.implementation = class BlobImpl {
|
||||
if (parts !== undefined) {
|
||||
for (const part of parts) {
|
||||
let buffer;
|
||||
if (part instanceof ArrayBuffer) {
|
||||
if (isArrayBuffer(part)) {
|
||||
buffer = Buffer.from(part);
|
||||
} else if (ArrayBuffer.isView(part)) {
|
||||
buffer = Buffer.from(part.buffer, part.byteOffset, part.byteLength);
|
||||
@@ -34,6 +36,7 @@ exports.implementation = class BlobImpl {
|
||||
}
|
||||
|
||||
this._buffer = Buffer.concat(buffers);
|
||||
this._globalObject = globalObject;
|
||||
|
||||
this.type = properties.type;
|
||||
if (/[^\u0020-\u007E]/.test(this.type)) {
|
||||
@@ -85,7 +88,7 @@ exports.implementation = class BlobImpl {
|
||||
relativeStart + span
|
||||
);
|
||||
|
||||
const blob = Blob.createImpl([[], { type: relativeContentType }], {});
|
||||
const blob = Blob.createImpl(this._globalObject, [[], { type: relativeContentType }], {});
|
||||
blob._buffer = slicedBuffer;
|
||||
return blob;
|
||||
}
|
||||
|
||||
4
node_modules/jsdom/lib/jsdom/living/file-api/File-impl.js
generated
vendored
4
node_modules/jsdom/lib/jsdom/living/file-api/File-impl.js
generated
vendored
@@ -3,11 +3,11 @@
|
||||
const BlobImpl = require("./Blob-impl").implementation;
|
||||
|
||||
exports.implementation = class FileImpl extends BlobImpl {
|
||||
constructor(args, privateData) {
|
||||
constructor(globalObject, args, privateData) {
|
||||
const fileBits = args[0];
|
||||
const fileName = args[1];
|
||||
const options = args[2];
|
||||
super([fileBits, options], privateData);
|
||||
super(globalObject, [fileBits, options], privateData);
|
||||
|
||||
this.name = fileName.replace(/\//g, ":");
|
||||
this.lastModified = "lastModified" in options ? options.lastModified : Date.now();
|
||||
|
||||
45
node_modules/jsdom/lib/jsdom/living/file-api/FileReader-impl.js
generated
vendored
45
node_modules/jsdom/lib/jsdom/living/file-api/FileReader-impl.js
generated
vendored
@@ -2,11 +2,12 @@
|
||||
|
||||
const whatwgEncoding = require("whatwg-encoding");
|
||||
const MIMEType = require("whatwg-mimetype");
|
||||
const querystring = require("querystring");
|
||||
const DOMException = require("domexception");
|
||||
const DOMException = require("domexception/webidl2js-wrapper");
|
||||
const EventTargetImpl = require("../events/EventTarget-impl").implementation;
|
||||
const ProgressEvent = require("../generated/ProgressEvent");
|
||||
const { setupForSimpleEventAccessors } = require("../helpers/create-event-accessor");
|
||||
const { fireAnEvent } = require("../helpers/events");
|
||||
const { copyToArrayBufferInNewRealm } = require("../helpers/binary-data");
|
||||
|
||||
const READY_STATES = Object.freeze({
|
||||
EMPTY: 0,
|
||||
@@ -17,14 +18,15 @@ const READY_STATES = Object.freeze({
|
||||
const events = ["loadstart", "progress", "load", "abort", "error", "loadend"];
|
||||
|
||||
class FileReaderImpl extends EventTargetImpl {
|
||||
constructor(args, privateData) {
|
||||
super([], privateData);
|
||||
constructor(globalObject, args, privateData) {
|
||||
super(globalObject, args, privateData);
|
||||
|
||||
this.error = null;
|
||||
this.readyState = READY_STATES.EMPTY;
|
||||
this.result = null;
|
||||
|
||||
this._ownerDocument = privateData.window.document;
|
||||
this._globalObject = globalObject;
|
||||
this._ownerDocument = globalObject.document;
|
||||
this._terminated = false;
|
||||
}
|
||||
|
||||
@@ -58,13 +60,15 @@ class FileReaderImpl extends EventTargetImpl {
|
||||
}
|
||||
|
||||
_fireProgressEvent(name, props) {
|
||||
const event = ProgressEvent.createImpl([name, Object.assign({ bubbles: false, cancelable: false }, props)], {});
|
||||
this.dispatchEvent(event);
|
||||
fireAnEvent(name, this, ProgressEvent, props);
|
||||
}
|
||||
|
||||
_readFile(file, format, encoding) {
|
||||
if (this.readyState === READY_STATES.LOADING) {
|
||||
throw new DOMException("The object is in an invalid state.", "InvalidStateError");
|
||||
throw DOMException.create(this._globalObject, [
|
||||
"The object is in an invalid state.",
|
||||
"InvalidStateError"
|
||||
]);
|
||||
}
|
||||
|
||||
this.readyState = READY_STATES.LOADING;
|
||||
@@ -96,7 +100,7 @@ class FileReaderImpl extends EventTargetImpl {
|
||||
switch (format) {
|
||||
default:
|
||||
case "buffer": {
|
||||
this.result = (new Uint8Array(data)).buffer;
|
||||
this.result = copyToArrayBufferInNewRealm(data, this._globalObject);
|
||||
break;
|
||||
}
|
||||
case "binaryString": {
|
||||
@@ -104,26 +108,9 @@ class FileReaderImpl extends EventTargetImpl {
|
||||
break;
|
||||
}
|
||||
case "dataURL": {
|
||||
// Spec seems very unclear here; see https://github.com/whatwg/fetch/issues/665#issuecomment-362930079.
|
||||
let dataUrl = "data:";
|
||||
const contentType = MIMEType.parse(file.type);
|
||||
if (contentType && contentType.type === "text") {
|
||||
const fallbackEncoding = whatwgEncoding.getBOMEncoding(data) ||
|
||||
whatwgEncoding.labelToName(contentType.parameters.get("charset")) || "UTF-8";
|
||||
const decoded = whatwgEncoding.decode(data, fallbackEncoding);
|
||||
|
||||
contentType.parameters.set("charset", encoding);
|
||||
dataUrl += contentType.toString();
|
||||
dataUrl += ",";
|
||||
dataUrl += querystring.escape(decoded);
|
||||
} else {
|
||||
if (contentType) {
|
||||
dataUrl += contentType.toString();
|
||||
}
|
||||
dataUrl += ";base64,";
|
||||
dataUrl += data.toString("base64");
|
||||
}
|
||||
this.result = dataUrl;
|
||||
// Spec seems very unclear here; see https://github.com/w3c/FileAPI/issues/104.
|
||||
const contentType = MIMEType.parse(file.type) || "application/octet-stream";
|
||||
this.result = `data:${contentType};base64,${data.toString("base64")}`;
|
||||
break;
|
||||
}
|
||||
case "text": {
|
||||
|
||||
236
node_modules/jsdom/lib/jsdom/living/generated/AbortController.js
generated
vendored
236
node_modules/jsdom/lib/jsdom/living/generated/AbortController.js
generated
vendored
@@ -3,142 +3,128 @@
|
||||
const conversions = require("webidl-conversions");
|
||||
const utils = require("./utils.js");
|
||||
|
||||
const impl = utils.implSymbol;
|
||||
const implSymbol = utils.implSymbol;
|
||||
const ctorRegistrySymbol = utils.ctorRegistrySymbol;
|
||||
|
||||
module.exports = {
|
||||
createInterface: function(defaultPrivateData = {}) {
|
||||
function AbortController() {
|
||||
if (new.target === undefined) {
|
||||
throw new TypeError(
|
||||
"Failed to construct 'AbortController'. Please use the 'new' operator; this constructor " +
|
||||
"cannot be called as a function."
|
||||
);
|
||||
}
|
||||
const interfaceName = "AbortController";
|
||||
|
||||
iface.setup(this);
|
||||
exports.is = value => {
|
||||
return utils.isObject(value) && utils.hasOwn(value, implSymbol) && value[implSymbol] instanceof Impl.implementation;
|
||||
};
|
||||
exports.isImpl = value => {
|
||||
return utils.isObject(value) && value instanceof Impl.implementation;
|
||||
};
|
||||
exports.convert = (value, { context = "The provided value" } = {}) => {
|
||||
if (exports.is(value)) {
|
||||
return utils.implForWrapper(value);
|
||||
}
|
||||
throw new TypeError(`${context} is not of type 'AbortController'.`);
|
||||
};
|
||||
|
||||
function makeWrapper(globalObject) {
|
||||
if (globalObject[ctorRegistrySymbol] === undefined) {
|
||||
throw new Error("Internal error: invalid global object");
|
||||
}
|
||||
|
||||
const ctor = globalObject[ctorRegistrySymbol]["AbortController"];
|
||||
if (ctor === undefined) {
|
||||
throw new Error("Internal error: constructor AbortController is not installed on the passed global object");
|
||||
}
|
||||
|
||||
return Object.create(ctor.prototype);
|
||||
}
|
||||
|
||||
exports.create = (globalObject, constructorArgs, privateData) => {
|
||||
const wrapper = makeWrapper(globalObject);
|
||||
return exports.setup(wrapper, globalObject, constructorArgs, privateData);
|
||||
};
|
||||
|
||||
exports.createImpl = (globalObject, constructorArgs, privateData) => {
|
||||
const wrapper = exports.create(globalObject, constructorArgs, privateData);
|
||||
return utils.implForWrapper(wrapper);
|
||||
};
|
||||
|
||||
exports._internalSetup = (wrapper, globalObject) => {};
|
||||
|
||||
exports.setup = (wrapper, globalObject, constructorArgs = [], privateData = {}) => {
|
||||
privateData.wrapper = wrapper;
|
||||
|
||||
exports._internalSetup(wrapper, globalObject);
|
||||
Object.defineProperty(wrapper, implSymbol, {
|
||||
value: new Impl.implementation(globalObject, constructorArgs, privateData),
|
||||
configurable: true
|
||||
});
|
||||
|
||||
wrapper[implSymbol][utils.wrapperSymbol] = wrapper;
|
||||
if (Impl.init) {
|
||||
Impl.init(wrapper[implSymbol]);
|
||||
}
|
||||
return wrapper;
|
||||
};
|
||||
|
||||
exports.new = globalObject => {
|
||||
const wrapper = makeWrapper(globalObject);
|
||||
|
||||
exports._internalSetup(wrapper, globalObject);
|
||||
Object.defineProperty(wrapper, implSymbol, {
|
||||
value: Object.create(Impl.implementation.prototype),
|
||||
configurable: true
|
||||
});
|
||||
|
||||
wrapper[implSymbol][utils.wrapperSymbol] = wrapper;
|
||||
if (Impl.init) {
|
||||
Impl.init(wrapper[implSymbol]);
|
||||
}
|
||||
return wrapper[implSymbol];
|
||||
};
|
||||
|
||||
const exposed = new Set(["Window", "Worker"]);
|
||||
|
||||
exports.install = (globalObject, globalNames) => {
|
||||
if (!globalNames.some(globalName => exposed.has(globalName))) {
|
||||
return;
|
||||
}
|
||||
class AbortController {
|
||||
constructor() {
|
||||
return exports.setup(Object.create(new.target.prototype), globalObject, undefined);
|
||||
}
|
||||
|
||||
Object.defineProperty(AbortController, "prototype", {
|
||||
value: AbortController.prototype,
|
||||
writable: false,
|
||||
enumerable: false,
|
||||
configurable: false
|
||||
});
|
||||
|
||||
AbortController.prototype.abort = function abort() {
|
||||
if (!this || !module.exports.is(this)) {
|
||||
abort() {
|
||||
const esValue = this !== null && this !== undefined ? this : globalObject;
|
||||
if (!exports.is(esValue)) {
|
||||
throw new TypeError("Illegal invocation");
|
||||
}
|
||||
|
||||
return this[impl].abort();
|
||||
};
|
||||
|
||||
Object.defineProperty(AbortController.prototype, "signal", {
|
||||
get() {
|
||||
if (!this || !module.exports.is(this)) {
|
||||
throw new TypeError("Illegal invocation");
|
||||
}
|
||||
|
||||
return utils.getSameObject(this, "signal", () => {
|
||||
return utils.tryWrapperForImpl(this[impl]["signal"]);
|
||||
});
|
||||
},
|
||||
|
||||
enumerable: true,
|
||||
configurable: true
|
||||
});
|
||||
|
||||
Object.defineProperty(AbortController.prototype, Symbol.toStringTag, {
|
||||
value: "AbortController",
|
||||
writable: false,
|
||||
enumerable: false,
|
||||
configurable: true
|
||||
});
|
||||
|
||||
const iface = {
|
||||
create(constructorArgs, privateData) {
|
||||
let obj = Object.create(AbortController.prototype);
|
||||
obj = this.setup(obj, constructorArgs, privateData);
|
||||
return obj;
|
||||
},
|
||||
createImpl(constructorArgs, privateData) {
|
||||
let obj = Object.create(AbortController.prototype);
|
||||
obj = this.setup(obj, constructorArgs, privateData);
|
||||
return utils.implForWrapper(obj);
|
||||
},
|
||||
_internalSetup(obj) {},
|
||||
setup(obj, constructorArgs, privateData) {
|
||||
if (!privateData) privateData = {};
|
||||
|
||||
for (var prop in defaultPrivateData) {
|
||||
if (!(prop in privateData)) {
|
||||
privateData[prop] = defaultPrivateData[prop];
|
||||
}
|
||||
}
|
||||
|
||||
privateData.wrapper = obj;
|
||||
|
||||
this._internalSetup(obj);
|
||||
Object.defineProperty(obj, impl, {
|
||||
value: new Impl.implementation(constructorArgs, privateData),
|
||||
writable: false,
|
||||
enumerable: false,
|
||||
configurable: true
|
||||
});
|
||||
|
||||
obj[impl][utils.wrapperSymbol] = obj;
|
||||
if (Impl.init) {
|
||||
Impl.init(obj[impl], privateData);
|
||||
}
|
||||
return obj;
|
||||
},
|
||||
interface: AbortController,
|
||||
expose: {
|
||||
Window: { AbortController },
|
||||
Worker: { AbortController }
|
||||
}
|
||||
}; // iface
|
||||
return iface;
|
||||
}, // createInterface
|
||||
|
||||
// When an interface-module that implements this interface as a mixin is loaded, it will append its own `.is()`
|
||||
// method into this array. It allows objects that directly implements *those* interfaces to be recognized as
|
||||
// implementing this mixin interface.
|
||||
_mixedIntoPredicates: [],
|
||||
is(obj) {
|
||||
if (obj) {
|
||||
if (utils.hasOwn(obj, impl) && obj[impl] instanceof Impl.implementation) {
|
||||
return true;
|
||||
}
|
||||
for (const isMixedInto of module.exports._mixedIntoPredicates) {
|
||||
if (isMixedInto(obj)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return esValue[implSymbol].abort();
|
||||
}
|
||||
return false;
|
||||
},
|
||||
isImpl(obj) {
|
||||
if (obj) {
|
||||
if (obj instanceof Impl.implementation) {
|
||||
return true;
|
||||
|
||||
get signal() {
|
||||
const esValue = this !== null && this !== undefined ? this : globalObject;
|
||||
|
||||
if (!exports.is(esValue)) {
|
||||
throw new TypeError("Illegal invocation");
|
||||
}
|
||||
|
||||
const wrapper = utils.wrapperForImpl(obj);
|
||||
for (const isMixedInto of module.exports._mixedIntoPredicates) {
|
||||
if (isMixedInto(wrapper)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return utils.getSameObject(this, "signal", () => {
|
||||
return utils.tryWrapperForImpl(esValue[implSymbol]["signal"]);
|
||||
});
|
||||
}
|
||||
return false;
|
||||
},
|
||||
convert(obj, { context = "The provided value" } = {}) {
|
||||
if (module.exports.is(obj)) {
|
||||
return utils.implForWrapper(obj);
|
||||
}
|
||||
throw new TypeError(`${context} is not of type 'AbortController'.`);
|
||||
}
|
||||
}; // module.exports
|
||||
Object.defineProperties(AbortController.prototype, {
|
||||
abort: { enumerable: true },
|
||||
signal: { enumerable: true },
|
||||
[Symbol.toStringTag]: { value: "AbortController", configurable: true }
|
||||
});
|
||||
if (globalObject[ctorRegistrySymbol] === undefined) {
|
||||
globalObject[ctorRegistrySymbol] = Object.create(null);
|
||||
}
|
||||
globalObject[ctorRegistrySymbol][interfaceName] = AbortController;
|
||||
|
||||
Object.defineProperty(globalObject, interfaceName, {
|
||||
configurable: true,
|
||||
writable: true,
|
||||
value: AbortController
|
||||
});
|
||||
};
|
||||
|
||||
const Impl = require("../aborting/AbortController-impl.js");
|
||||
|
||||
262
node_modules/jsdom/lib/jsdom/living/generated/AbortSignal.js
generated
vendored
262
node_modules/jsdom/lib/jsdom/living/generated/AbortSignal.js
generated
vendored
@@ -3,154 +3,146 @@
|
||||
const conversions = require("webidl-conversions");
|
||||
const utils = require("./utils.js");
|
||||
|
||||
const impl = utils.implSymbol;
|
||||
const implSymbol = utils.implSymbol;
|
||||
const ctorRegistrySymbol = utils.ctorRegistrySymbol;
|
||||
const EventTarget = require("./EventTarget.js");
|
||||
|
||||
module.exports = {
|
||||
createInterface: function(defaultPrivateData = {}) {
|
||||
function AbortSignal() {
|
||||
const interfaceName = "AbortSignal";
|
||||
|
||||
exports.is = value => {
|
||||
return utils.isObject(value) && utils.hasOwn(value, implSymbol) && value[implSymbol] instanceof Impl.implementation;
|
||||
};
|
||||
exports.isImpl = value => {
|
||||
return utils.isObject(value) && value instanceof Impl.implementation;
|
||||
};
|
||||
exports.convert = (value, { context = "The provided value" } = {}) => {
|
||||
if (exports.is(value)) {
|
||||
return utils.implForWrapper(value);
|
||||
}
|
||||
throw new TypeError(`${context} is not of type 'AbortSignal'.`);
|
||||
};
|
||||
|
||||
function makeWrapper(globalObject) {
|
||||
if (globalObject[ctorRegistrySymbol] === undefined) {
|
||||
throw new Error("Internal error: invalid global object");
|
||||
}
|
||||
|
||||
const ctor = globalObject[ctorRegistrySymbol]["AbortSignal"];
|
||||
if (ctor === undefined) {
|
||||
throw new Error("Internal error: constructor AbortSignal is not installed on the passed global object");
|
||||
}
|
||||
|
||||
return Object.create(ctor.prototype);
|
||||
}
|
||||
|
||||
exports.create = (globalObject, constructorArgs, privateData) => {
|
||||
const wrapper = makeWrapper(globalObject);
|
||||
return exports.setup(wrapper, globalObject, constructorArgs, privateData);
|
||||
};
|
||||
|
||||
exports.createImpl = (globalObject, constructorArgs, privateData) => {
|
||||
const wrapper = exports.create(globalObject, constructorArgs, privateData);
|
||||
return utils.implForWrapper(wrapper);
|
||||
};
|
||||
|
||||
exports._internalSetup = (wrapper, globalObject) => {
|
||||
EventTarget._internalSetup(wrapper, globalObject);
|
||||
};
|
||||
|
||||
exports.setup = (wrapper, globalObject, constructorArgs = [], privateData = {}) => {
|
||||
privateData.wrapper = wrapper;
|
||||
|
||||
exports._internalSetup(wrapper, globalObject);
|
||||
Object.defineProperty(wrapper, implSymbol, {
|
||||
value: new Impl.implementation(globalObject, constructorArgs, privateData),
|
||||
configurable: true
|
||||
});
|
||||
|
||||
wrapper[implSymbol][utils.wrapperSymbol] = wrapper;
|
||||
if (Impl.init) {
|
||||
Impl.init(wrapper[implSymbol]);
|
||||
}
|
||||
return wrapper;
|
||||
};
|
||||
|
||||
exports.new = globalObject => {
|
||||
const wrapper = makeWrapper(globalObject);
|
||||
|
||||
exports._internalSetup(wrapper, globalObject);
|
||||
Object.defineProperty(wrapper, implSymbol, {
|
||||
value: Object.create(Impl.implementation.prototype),
|
||||
configurable: true
|
||||
});
|
||||
|
||||
wrapper[implSymbol][utils.wrapperSymbol] = wrapper;
|
||||
if (Impl.init) {
|
||||
Impl.init(wrapper[implSymbol]);
|
||||
}
|
||||
return wrapper[implSymbol];
|
||||
};
|
||||
|
||||
const exposed = new Set(["Window", "Worker"]);
|
||||
|
||||
exports.install = (globalObject, globalNames) => {
|
||||
if (!globalNames.some(globalName => exposed.has(globalName))) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (globalObject.EventTarget === undefined) {
|
||||
throw new Error("Internal error: attempting to evaluate AbortSignal before EventTarget");
|
||||
}
|
||||
class AbortSignal extends globalObject.EventTarget {
|
||||
constructor() {
|
||||
throw new TypeError("Illegal constructor");
|
||||
}
|
||||
|
||||
Object.setPrototypeOf(AbortSignal.prototype, EventTarget.interface.prototype);
|
||||
Object.setPrototypeOf(AbortSignal, EventTarget.interface);
|
||||
get aborted() {
|
||||
const esValue = this !== null && this !== undefined ? this : globalObject;
|
||||
|
||||
Object.defineProperty(AbortSignal, "prototype", {
|
||||
value: AbortSignal.prototype,
|
||||
writable: false,
|
||||
enumerable: false,
|
||||
configurable: false
|
||||
});
|
||||
|
||||
Object.defineProperty(AbortSignal.prototype, "aborted", {
|
||||
get() {
|
||||
if (!this || !module.exports.is(this)) {
|
||||
throw new TypeError("Illegal invocation");
|
||||
}
|
||||
|
||||
return this[impl]["aborted"];
|
||||
},
|
||||
|
||||
enumerable: true,
|
||||
configurable: true
|
||||
});
|
||||
|
||||
Object.defineProperty(AbortSignal.prototype, "onabort", {
|
||||
get() {
|
||||
if (!this || !module.exports.is(this)) {
|
||||
throw new TypeError("Illegal invocation");
|
||||
}
|
||||
|
||||
return utils.tryWrapperForImpl(this[impl]["onabort"]);
|
||||
},
|
||||
|
||||
set(V) {
|
||||
if (!this || !module.exports.is(this)) {
|
||||
throw new TypeError("Illegal invocation");
|
||||
}
|
||||
|
||||
V = utils.tryImplForWrapper(V);
|
||||
|
||||
this[impl]["onabort"] = V;
|
||||
},
|
||||
|
||||
enumerable: true,
|
||||
configurable: true
|
||||
});
|
||||
|
||||
Object.defineProperty(AbortSignal.prototype, Symbol.toStringTag, {
|
||||
value: "AbortSignal",
|
||||
writable: false,
|
||||
enumerable: false,
|
||||
configurable: true
|
||||
});
|
||||
|
||||
const iface = {
|
||||
create(constructorArgs, privateData) {
|
||||
let obj = Object.create(AbortSignal.prototype);
|
||||
obj = this.setup(obj, constructorArgs, privateData);
|
||||
return obj;
|
||||
},
|
||||
createImpl(constructorArgs, privateData) {
|
||||
let obj = Object.create(AbortSignal.prototype);
|
||||
obj = this.setup(obj, constructorArgs, privateData);
|
||||
return utils.implForWrapper(obj);
|
||||
},
|
||||
_internalSetup(obj) {
|
||||
EventTarget._internalSetup(obj);
|
||||
},
|
||||
setup(obj, constructorArgs, privateData) {
|
||||
if (!privateData) privateData = {};
|
||||
|
||||
for (var prop in defaultPrivateData) {
|
||||
if (!(prop in privateData)) {
|
||||
privateData[prop] = defaultPrivateData[prop];
|
||||
}
|
||||
}
|
||||
|
||||
privateData.wrapper = obj;
|
||||
|
||||
this._internalSetup(obj);
|
||||
Object.defineProperty(obj, impl, {
|
||||
value: new Impl.implementation(constructorArgs, privateData),
|
||||
writable: false,
|
||||
enumerable: false,
|
||||
configurable: true
|
||||
});
|
||||
|
||||
obj[impl][utils.wrapperSymbol] = obj;
|
||||
if (Impl.init) {
|
||||
Impl.init(obj[impl], privateData);
|
||||
}
|
||||
return obj;
|
||||
},
|
||||
interface: AbortSignal,
|
||||
expose: {
|
||||
Window: { AbortSignal },
|
||||
Worker: { AbortSignal }
|
||||
if (!exports.is(esValue)) {
|
||||
throw new TypeError("Illegal invocation");
|
||||
}
|
||||
}; // iface
|
||||
return iface;
|
||||
}, // createInterface
|
||||
|
||||
// When an interface-module that implements this interface as a mixin is loaded, it will append its own `.is()`
|
||||
// method into this array. It allows objects that directly implements *those* interfaces to be recognized as
|
||||
// implementing this mixin interface.
|
||||
_mixedIntoPredicates: [],
|
||||
is(obj) {
|
||||
if (obj) {
|
||||
if (utils.hasOwn(obj, impl) && obj[impl] instanceof Impl.implementation) {
|
||||
return true;
|
||||
}
|
||||
for (const isMixedInto of module.exports._mixedIntoPredicates) {
|
||||
if (isMixedInto(obj)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return esValue[implSymbol]["aborted"];
|
||||
}
|
||||
return false;
|
||||
},
|
||||
isImpl(obj) {
|
||||
if (obj) {
|
||||
if (obj instanceof Impl.implementation) {
|
||||
return true;
|
||||
|
||||
get onabort() {
|
||||
const esValue = this !== null && this !== undefined ? this : globalObject;
|
||||
|
||||
if (!exports.is(esValue)) {
|
||||
throw new TypeError("Illegal invocation");
|
||||
}
|
||||
|
||||
const wrapper = utils.wrapperForImpl(obj);
|
||||
for (const isMixedInto of module.exports._mixedIntoPredicates) {
|
||||
if (isMixedInto(wrapper)) {
|
||||
return true;
|
||||
}
|
||||
return utils.tryWrapperForImpl(esValue[implSymbol]["onabort"]);
|
||||
}
|
||||
|
||||
set onabort(V) {
|
||||
const esValue = this !== null && this !== undefined ? this : globalObject;
|
||||
|
||||
if (!exports.is(esValue)) {
|
||||
throw new TypeError("Illegal invocation");
|
||||
}
|
||||
|
||||
V = utils.tryImplForWrapper(V);
|
||||
|
||||
esValue[implSymbol]["onabort"] = V;
|
||||
}
|
||||
return false;
|
||||
},
|
||||
convert(obj, { context = "The provided value" } = {}) {
|
||||
if (module.exports.is(obj)) {
|
||||
return utils.implForWrapper(obj);
|
||||
}
|
||||
throw new TypeError(`${context} is not of type 'AbortSignal'.`);
|
||||
}
|
||||
}; // module.exports
|
||||
Object.defineProperties(AbortSignal.prototype, {
|
||||
aborted: { enumerable: true },
|
||||
onabort: { enumerable: true },
|
||||
[Symbol.toStringTag]: { value: "AbortSignal", configurable: true }
|
||||
});
|
||||
if (globalObject[ctorRegistrySymbol] === undefined) {
|
||||
globalObject[ctorRegistrySymbol] = Object.create(null);
|
||||
}
|
||||
globalObject[ctorRegistrySymbol][interfaceName] = AbortSignal;
|
||||
|
||||
Object.defineProperty(globalObject, interfaceName, {
|
||||
configurable: true,
|
||||
writable: true,
|
||||
value: AbortSignal
|
||||
});
|
||||
};
|
||||
|
||||
const Impl = require("../aborting/AbortSignal-impl.js");
|
||||
|
||||
162
node_modules/jsdom/lib/jsdom/living/generated/AbstractRange.js
generated
vendored
Normal file
162
node_modules/jsdom/lib/jsdom/living/generated/AbstractRange.js
generated
vendored
Normal file
@@ -0,0 +1,162 @@
|
||||
"use strict";
|
||||
|
||||
const conversions = require("webidl-conversions");
|
||||
const utils = require("./utils.js");
|
||||
|
||||
const implSymbol = utils.implSymbol;
|
||||
const ctorRegistrySymbol = utils.ctorRegistrySymbol;
|
||||
|
||||
const interfaceName = "AbstractRange";
|
||||
|
||||
exports.is = value => {
|
||||
return utils.isObject(value) && utils.hasOwn(value, implSymbol) && value[implSymbol] instanceof Impl.implementation;
|
||||
};
|
||||
exports.isImpl = value => {
|
||||
return utils.isObject(value) && value instanceof Impl.implementation;
|
||||
};
|
||||
exports.convert = (value, { context = "The provided value" } = {}) => {
|
||||
if (exports.is(value)) {
|
||||
return utils.implForWrapper(value);
|
||||
}
|
||||
throw new TypeError(`${context} is not of type 'AbstractRange'.`);
|
||||
};
|
||||
|
||||
function makeWrapper(globalObject) {
|
||||
if (globalObject[ctorRegistrySymbol] === undefined) {
|
||||
throw new Error("Internal error: invalid global object");
|
||||
}
|
||||
|
||||
const ctor = globalObject[ctorRegistrySymbol]["AbstractRange"];
|
||||
if (ctor === undefined) {
|
||||
throw new Error("Internal error: constructor AbstractRange is not installed on the passed global object");
|
||||
}
|
||||
|
||||
return Object.create(ctor.prototype);
|
||||
}
|
||||
|
||||
exports.create = (globalObject, constructorArgs, privateData) => {
|
||||
const wrapper = makeWrapper(globalObject);
|
||||
return exports.setup(wrapper, globalObject, constructorArgs, privateData);
|
||||
};
|
||||
|
||||
exports.createImpl = (globalObject, constructorArgs, privateData) => {
|
||||
const wrapper = exports.create(globalObject, constructorArgs, privateData);
|
||||
return utils.implForWrapper(wrapper);
|
||||
};
|
||||
|
||||
exports._internalSetup = (wrapper, globalObject) => {};
|
||||
|
||||
exports.setup = (wrapper, globalObject, constructorArgs = [], privateData = {}) => {
|
||||
privateData.wrapper = wrapper;
|
||||
|
||||
exports._internalSetup(wrapper, globalObject);
|
||||
Object.defineProperty(wrapper, implSymbol, {
|
||||
value: new Impl.implementation(globalObject, constructorArgs, privateData),
|
||||
configurable: true
|
||||
});
|
||||
|
||||
wrapper[implSymbol][utils.wrapperSymbol] = wrapper;
|
||||
if (Impl.init) {
|
||||
Impl.init(wrapper[implSymbol]);
|
||||
}
|
||||
return wrapper;
|
||||
};
|
||||
|
||||
exports.new = globalObject => {
|
||||
const wrapper = makeWrapper(globalObject);
|
||||
|
||||
exports._internalSetup(wrapper, globalObject);
|
||||
Object.defineProperty(wrapper, implSymbol, {
|
||||
value: Object.create(Impl.implementation.prototype),
|
||||
configurable: true
|
||||
});
|
||||
|
||||
wrapper[implSymbol][utils.wrapperSymbol] = wrapper;
|
||||
if (Impl.init) {
|
||||
Impl.init(wrapper[implSymbol]);
|
||||
}
|
||||
return wrapper[implSymbol];
|
||||
};
|
||||
|
||||
const exposed = new Set(["Window"]);
|
||||
|
||||
exports.install = (globalObject, globalNames) => {
|
||||
if (!globalNames.some(globalName => exposed.has(globalName))) {
|
||||
return;
|
||||
}
|
||||
class AbstractRange {
|
||||
constructor() {
|
||||
throw new TypeError("Illegal constructor");
|
||||
}
|
||||
|
||||
get startContainer() {
|
||||
const esValue = this !== null && this !== undefined ? this : globalObject;
|
||||
|
||||
if (!exports.is(esValue)) {
|
||||
throw new TypeError("Illegal invocation");
|
||||
}
|
||||
|
||||
return utils.tryWrapperForImpl(esValue[implSymbol]["startContainer"]);
|
||||
}
|
||||
|
||||
get startOffset() {
|
||||
const esValue = this !== null && this !== undefined ? this : globalObject;
|
||||
|
||||
if (!exports.is(esValue)) {
|
||||
throw new TypeError("Illegal invocation");
|
||||
}
|
||||
|
||||
return esValue[implSymbol]["startOffset"];
|
||||
}
|
||||
|
||||
get endContainer() {
|
||||
const esValue = this !== null && this !== undefined ? this : globalObject;
|
||||
|
||||
if (!exports.is(esValue)) {
|
||||
throw new TypeError("Illegal invocation");
|
||||
}
|
||||
|
||||
return utils.tryWrapperForImpl(esValue[implSymbol]["endContainer"]);
|
||||
}
|
||||
|
||||
get endOffset() {
|
||||
const esValue = this !== null && this !== undefined ? this : globalObject;
|
||||
|
||||
if (!exports.is(esValue)) {
|
||||
throw new TypeError("Illegal invocation");
|
||||
}
|
||||
|
||||
return esValue[implSymbol]["endOffset"];
|
||||
}
|
||||
|
||||
get collapsed() {
|
||||
const esValue = this !== null && this !== undefined ? this : globalObject;
|
||||
|
||||
if (!exports.is(esValue)) {
|
||||
throw new TypeError("Illegal invocation");
|
||||
}
|
||||
|
||||
return esValue[implSymbol]["collapsed"];
|
||||
}
|
||||
}
|
||||
Object.defineProperties(AbstractRange.prototype, {
|
||||
startContainer: { enumerable: true },
|
||||
startOffset: { enumerable: true },
|
||||
endContainer: { enumerable: true },
|
||||
endOffset: { enumerable: true },
|
||||
collapsed: { enumerable: true },
|
||||
[Symbol.toStringTag]: { value: "AbstractRange", configurable: true }
|
||||
});
|
||||
if (globalObject[ctorRegistrySymbol] === undefined) {
|
||||
globalObject[ctorRegistrySymbol] = Object.create(null);
|
||||
}
|
||||
globalObject[ctorRegistrySymbol][interfaceName] = AbstractRange;
|
||||
|
||||
Object.defineProperty(globalObject, interfaceName, {
|
||||
configurable: true,
|
||||
writable: true,
|
||||
value: AbstractRange
|
||||
});
|
||||
};
|
||||
|
||||
const Impl = require("../range/AbstractRange-impl.js");
|
||||
50
node_modules/jsdom/lib/jsdom/living/generated/AddEventListenerOptions.js
generated
vendored
50
node_modules/jsdom/lib/jsdom/living/generated/AddEventListenerOptions.js
generated
vendored
@@ -5,30 +5,40 @@ const utils = require("./utils.js");
|
||||
|
||||
const EventListenerOptions = require("./EventListenerOptions.js");
|
||||
|
||||
module.exports = {
|
||||
convertInherit(obj, ret, { context = "The provided value" } = {}) {
|
||||
EventListenerOptions.convertInherit(obj, ret, { context });
|
||||
exports._convertInherit = (obj, ret, { context = "The provided value" } = {}) => {
|
||||
EventListenerOptions._convertInherit(obj, ret, { context });
|
||||
|
||||
{
|
||||
const key = "once";
|
||||
let value = obj === undefined || obj === null ? undefined : obj[key];
|
||||
if (value !== undefined) {
|
||||
value = conversions["boolean"](value, { context: context + " has member once that" });
|
||||
{
|
||||
const key = "once";
|
||||
let value = obj === undefined || obj === null ? undefined : obj[key];
|
||||
if (value !== undefined) {
|
||||
value = conversions["boolean"](value, { context: context + " has member 'once' that" });
|
||||
|
||||
ret[key] = value;
|
||||
} else {
|
||||
ret[key] = false;
|
||||
}
|
||||
ret[key] = value;
|
||||
} else {
|
||||
ret[key] = false;
|
||||
}
|
||||
},
|
||||
}
|
||||
|
||||
convert(obj, { context = "The provided value" } = {}) {
|
||||
if (obj !== undefined && typeof obj !== "object" && typeof obj !== "function") {
|
||||
throw new TypeError(`${context} is not an object.`);
|
||||
{
|
||||
const key = "passive";
|
||||
let value = obj === undefined || obj === null ? undefined : obj[key];
|
||||
if (value !== undefined) {
|
||||
value = conversions["boolean"](value, { context: context + " has member 'passive' that" });
|
||||
|
||||
ret[key] = value;
|
||||
} else {
|
||||
ret[key] = false;
|
||||
}
|
||||
|
||||
const ret = Object.create(null);
|
||||
module.exports.convertInherit(obj, ret, { context });
|
||||
return ret;
|
||||
}
|
||||
};
|
||||
|
||||
exports.convert = function convert(obj, { context = "The provided value" } = {}) {
|
||||
if (obj !== undefined && typeof obj !== "object" && typeof obj !== "function") {
|
||||
throw new TypeError(`${context} is not an object.`);
|
||||
}
|
||||
|
||||
const ret = Object.create(null);
|
||||
exports._convertInherit(obj, ret, { context });
|
||||
return ret;
|
||||
};
|
||||
|
||||
28
node_modules/jsdom/lib/jsdom/living/generated/AssignedNodesOptions.js
generated
vendored
Normal file
28
node_modules/jsdom/lib/jsdom/living/generated/AssignedNodesOptions.js
generated
vendored
Normal file
@@ -0,0 +1,28 @@
|
||||
"use strict";
|
||||
|
||||
const conversions = require("webidl-conversions");
|
||||
const utils = require("./utils.js");
|
||||
|
||||
exports._convertInherit = (obj, ret, { context = "The provided value" } = {}) => {
|
||||
{
|
||||
const key = "flatten";
|
||||
let value = obj === undefined || obj === null ? undefined : obj[key];
|
||||
if (value !== undefined) {
|
||||
value = conversions["boolean"](value, { context: context + " has member 'flatten' that" });
|
||||
|
||||
ret[key] = value;
|
||||
} else {
|
||||
ret[key] = false;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
exports.convert = function convert(obj, { context = "The provided value" } = {}) {
|
||||
if (obj !== undefined && typeof obj !== "object" && typeof obj !== "function") {
|
||||
throw new TypeError(`${context} is not an object.`);
|
||||
}
|
||||
|
||||
const ret = Object.create(null);
|
||||
exports._convertInherit(obj, ret, { context });
|
||||
return ret;
|
||||
};
|
||||
452
node_modules/jsdom/lib/jsdom/living/generated/Attr.js
generated
vendored
452
node_modules/jsdom/lib/jsdom/living/generated/Attr.js
generated
vendored
@@ -3,267 +3,213 @@
|
||||
const conversions = require("webidl-conversions");
|
||||
const utils = require("./utils.js");
|
||||
|
||||
const impl = utils.implSymbol;
|
||||
const ceReactionsPreSteps_helpers_custom_elements = require("../helpers/custom-elements.js").ceReactionsPreSteps;
|
||||
const ceReactionsPostSteps_helpers_custom_elements = require("../helpers/custom-elements.js").ceReactionsPostSteps;
|
||||
const implSymbol = utils.implSymbol;
|
||||
const ctorRegistrySymbol = utils.ctorRegistrySymbol;
|
||||
const Node = require("./Node.js");
|
||||
|
||||
function Attr() {
|
||||
throw new TypeError("Illegal constructor");
|
||||
const interfaceName = "Attr";
|
||||
|
||||
exports.is = value => {
|
||||
return utils.isObject(value) && utils.hasOwn(value, implSymbol) && value[implSymbol] instanceof Impl.implementation;
|
||||
};
|
||||
exports.isImpl = value => {
|
||||
return utils.isObject(value) && value instanceof Impl.implementation;
|
||||
};
|
||||
exports.convert = (value, { context = "The provided value" } = {}) => {
|
||||
if (exports.is(value)) {
|
||||
return utils.implForWrapper(value);
|
||||
}
|
||||
throw new TypeError(`${context} is not of type 'Attr'.`);
|
||||
};
|
||||
|
||||
function makeWrapper(globalObject) {
|
||||
if (globalObject[ctorRegistrySymbol] === undefined) {
|
||||
throw new Error("Internal error: invalid global object");
|
||||
}
|
||||
|
||||
const ctor = globalObject[ctorRegistrySymbol]["Attr"];
|
||||
if (ctor === undefined) {
|
||||
throw new Error("Internal error: constructor Attr is not installed on the passed global object");
|
||||
}
|
||||
|
||||
return Object.create(ctor.prototype);
|
||||
}
|
||||
|
||||
Object.defineProperty(Attr, "prototype", {
|
||||
value: Attr.prototype,
|
||||
writable: false,
|
||||
enumerable: false,
|
||||
configurable: false
|
||||
});
|
||||
exports.create = (globalObject, constructorArgs, privateData) => {
|
||||
const wrapper = makeWrapper(globalObject);
|
||||
return exports.setup(wrapper, globalObject, constructorArgs, privateData);
|
||||
};
|
||||
|
||||
Object.defineProperty(Attr.prototype, "namespaceURI", {
|
||||
get() {
|
||||
if (!this || !module.exports.is(this)) {
|
||||
throw new TypeError("Illegal invocation");
|
||||
}
|
||||
exports.createImpl = (globalObject, constructorArgs, privateData) => {
|
||||
const wrapper = exports.create(globalObject, constructorArgs, privateData);
|
||||
return utils.implForWrapper(wrapper);
|
||||
};
|
||||
|
||||
return this[impl]["namespaceURI"];
|
||||
},
|
||||
exports._internalSetup = (wrapper, globalObject) => {
|
||||
Node._internalSetup(wrapper, globalObject);
|
||||
};
|
||||
|
||||
enumerable: true,
|
||||
configurable: true
|
||||
});
|
||||
exports.setup = (wrapper, globalObject, constructorArgs = [], privateData = {}) => {
|
||||
privateData.wrapper = wrapper;
|
||||
|
||||
Object.defineProperty(Attr.prototype, "prefix", {
|
||||
get() {
|
||||
if (!this || !module.exports.is(this)) {
|
||||
throw new TypeError("Illegal invocation");
|
||||
}
|
||||
exports._internalSetup(wrapper, globalObject);
|
||||
Object.defineProperty(wrapper, implSymbol, {
|
||||
value: new Impl.implementation(globalObject, constructorArgs, privateData),
|
||||
configurable: true
|
||||
});
|
||||
|
||||
return this[impl]["prefix"];
|
||||
},
|
||||
|
||||
enumerable: true,
|
||||
configurable: true
|
||||
});
|
||||
|
||||
Object.defineProperty(Attr.prototype, "localName", {
|
||||
get() {
|
||||
if (!this || !module.exports.is(this)) {
|
||||
throw new TypeError("Illegal invocation");
|
||||
}
|
||||
|
||||
return this[impl]["localName"];
|
||||
},
|
||||
|
||||
enumerable: true,
|
||||
configurable: true
|
||||
});
|
||||
|
||||
Object.defineProperty(Attr.prototype, "name", {
|
||||
get() {
|
||||
if (!this || !module.exports.is(this)) {
|
||||
throw new TypeError("Illegal invocation");
|
||||
}
|
||||
|
||||
return this[impl]["name"];
|
||||
},
|
||||
|
||||
enumerable: true,
|
||||
configurable: true
|
||||
});
|
||||
|
||||
Object.defineProperty(Attr.prototype, "nodeName", {
|
||||
get() {
|
||||
if (!this || !module.exports.is(this)) {
|
||||
throw new TypeError("Illegal invocation");
|
||||
}
|
||||
|
||||
return this[impl]["nodeName"];
|
||||
},
|
||||
|
||||
enumerable: true,
|
||||
configurable: true
|
||||
});
|
||||
|
||||
Object.defineProperty(Attr.prototype, "value", {
|
||||
get() {
|
||||
if (!this || !module.exports.is(this)) {
|
||||
throw new TypeError("Illegal invocation");
|
||||
}
|
||||
|
||||
return this[impl]["value"];
|
||||
},
|
||||
|
||||
set(V) {
|
||||
if (!this || !module.exports.is(this)) {
|
||||
throw new TypeError("Illegal invocation");
|
||||
}
|
||||
|
||||
V = conversions["DOMString"](V, { context: "Failed to set the 'value' property on 'Attr': The provided value" });
|
||||
|
||||
this[impl]["value"] = V;
|
||||
},
|
||||
|
||||
enumerable: true,
|
||||
configurable: true
|
||||
});
|
||||
|
||||
Object.defineProperty(Attr.prototype, "nodeValue", {
|
||||
get() {
|
||||
if (!this || !module.exports.is(this)) {
|
||||
throw new TypeError("Illegal invocation");
|
||||
}
|
||||
|
||||
return this[impl]["nodeValue"];
|
||||
},
|
||||
|
||||
set(V) {
|
||||
if (!this || !module.exports.is(this)) {
|
||||
throw new TypeError("Illegal invocation");
|
||||
}
|
||||
|
||||
V = conversions["DOMString"](V, {
|
||||
context: "Failed to set the 'nodeValue' property on 'Attr': The provided value",
|
||||
treatNullAsEmptyString: true
|
||||
});
|
||||
|
||||
this[impl]["nodeValue"] = V;
|
||||
},
|
||||
|
||||
enumerable: true,
|
||||
configurable: true
|
||||
});
|
||||
|
||||
Object.defineProperty(Attr.prototype, "textContent", {
|
||||
get() {
|
||||
if (!this || !module.exports.is(this)) {
|
||||
throw new TypeError("Illegal invocation");
|
||||
}
|
||||
|
||||
return this[impl]["textContent"];
|
||||
},
|
||||
|
||||
set(V) {
|
||||
if (!this || !module.exports.is(this)) {
|
||||
throw new TypeError("Illegal invocation");
|
||||
}
|
||||
|
||||
V = conversions["DOMString"](V, {
|
||||
context: "Failed to set the 'textContent' property on 'Attr': The provided value",
|
||||
treatNullAsEmptyString: true
|
||||
});
|
||||
|
||||
this[impl]["textContent"] = V;
|
||||
},
|
||||
|
||||
enumerable: true,
|
||||
configurable: true
|
||||
});
|
||||
|
||||
Object.defineProperty(Attr.prototype, "ownerElement", {
|
||||
get() {
|
||||
if (!this || !module.exports.is(this)) {
|
||||
throw new TypeError("Illegal invocation");
|
||||
}
|
||||
|
||||
return utils.tryWrapperForImpl(this[impl]["ownerElement"]);
|
||||
},
|
||||
|
||||
enumerable: true,
|
||||
configurable: true
|
||||
});
|
||||
|
||||
Object.defineProperty(Attr.prototype, "specified", {
|
||||
get() {
|
||||
if (!this || !module.exports.is(this)) {
|
||||
throw new TypeError("Illegal invocation");
|
||||
}
|
||||
|
||||
return this[impl]["specified"];
|
||||
},
|
||||
|
||||
enumerable: true,
|
||||
configurable: true
|
||||
});
|
||||
|
||||
Object.defineProperty(Attr.prototype, Symbol.toStringTag, {
|
||||
value: "Attr",
|
||||
writable: false,
|
||||
enumerable: false,
|
||||
configurable: true
|
||||
});
|
||||
|
||||
const iface = {
|
||||
// When an interface-module that implements this interface as a mixin is loaded, it will append its own `.is()`
|
||||
// method into this array. It allows objects that directly implements *those* interfaces to be recognized as
|
||||
// implementing this mixin interface.
|
||||
_mixedIntoPredicates: [],
|
||||
is(obj) {
|
||||
if (obj) {
|
||||
if (utils.hasOwn(obj, impl) && obj[impl] instanceof Impl.implementation) {
|
||||
return true;
|
||||
}
|
||||
for (const isMixedInto of module.exports._mixedIntoPredicates) {
|
||||
if (isMixedInto(obj)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
},
|
||||
isImpl(obj) {
|
||||
if (obj) {
|
||||
if (obj instanceof Impl.implementation) {
|
||||
return true;
|
||||
}
|
||||
|
||||
const wrapper = utils.wrapperForImpl(obj);
|
||||
for (const isMixedInto of module.exports._mixedIntoPredicates) {
|
||||
if (isMixedInto(wrapper)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
},
|
||||
convert(obj, { context = "The provided value" } = {}) {
|
||||
if (module.exports.is(obj)) {
|
||||
return utils.implForWrapper(obj);
|
||||
}
|
||||
throw new TypeError(`${context} is not of type 'Attr'.`);
|
||||
},
|
||||
|
||||
create(constructorArgs, privateData) {
|
||||
let obj = Object.create(Attr.prototype);
|
||||
obj = this.setup(obj, constructorArgs, privateData);
|
||||
return obj;
|
||||
},
|
||||
createImpl(constructorArgs, privateData) {
|
||||
let obj = Object.create(Attr.prototype);
|
||||
obj = this.setup(obj, constructorArgs, privateData);
|
||||
return utils.implForWrapper(obj);
|
||||
},
|
||||
_internalSetup(obj) {},
|
||||
setup(obj, constructorArgs, privateData) {
|
||||
if (!privateData) privateData = {};
|
||||
|
||||
privateData.wrapper = obj;
|
||||
|
||||
this._internalSetup(obj);
|
||||
Object.defineProperty(obj, impl, {
|
||||
value: new Impl.implementation(constructorArgs, privateData),
|
||||
writable: false,
|
||||
enumerable: false,
|
||||
configurable: true
|
||||
});
|
||||
|
||||
obj[impl][utils.wrapperSymbol] = obj;
|
||||
if (Impl.init) {
|
||||
Impl.init(obj[impl], privateData);
|
||||
}
|
||||
return obj;
|
||||
},
|
||||
interface: Attr,
|
||||
expose: {
|
||||
Window: { Attr }
|
||||
wrapper[implSymbol][utils.wrapperSymbol] = wrapper;
|
||||
if (Impl.init) {
|
||||
Impl.init(wrapper[implSymbol]);
|
||||
}
|
||||
}; // iface
|
||||
module.exports = iface;
|
||||
return wrapper;
|
||||
};
|
||||
|
||||
exports.new = globalObject => {
|
||||
const wrapper = makeWrapper(globalObject);
|
||||
|
||||
exports._internalSetup(wrapper, globalObject);
|
||||
Object.defineProperty(wrapper, implSymbol, {
|
||||
value: Object.create(Impl.implementation.prototype),
|
||||
configurable: true
|
||||
});
|
||||
|
||||
wrapper[implSymbol][utils.wrapperSymbol] = wrapper;
|
||||
if (Impl.init) {
|
||||
Impl.init(wrapper[implSymbol]);
|
||||
}
|
||||
return wrapper[implSymbol];
|
||||
};
|
||||
|
||||
const exposed = new Set(["Window"]);
|
||||
|
||||
exports.install = (globalObject, globalNames) => {
|
||||
if (!globalNames.some(globalName => exposed.has(globalName))) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (globalObject.Node === undefined) {
|
||||
throw new Error("Internal error: attempting to evaluate Attr before Node");
|
||||
}
|
||||
class Attr extends globalObject.Node {
|
||||
constructor() {
|
||||
throw new TypeError("Illegal constructor");
|
||||
}
|
||||
|
||||
get namespaceURI() {
|
||||
const esValue = this !== null && this !== undefined ? this : globalObject;
|
||||
|
||||
if (!exports.is(esValue)) {
|
||||
throw new TypeError("Illegal invocation");
|
||||
}
|
||||
|
||||
return esValue[implSymbol]["namespaceURI"];
|
||||
}
|
||||
|
||||
get prefix() {
|
||||
const esValue = this !== null && this !== undefined ? this : globalObject;
|
||||
|
||||
if (!exports.is(esValue)) {
|
||||
throw new TypeError("Illegal invocation");
|
||||
}
|
||||
|
||||
return esValue[implSymbol]["prefix"];
|
||||
}
|
||||
|
||||
get localName() {
|
||||
const esValue = this !== null && this !== undefined ? this : globalObject;
|
||||
|
||||
if (!exports.is(esValue)) {
|
||||
throw new TypeError("Illegal invocation");
|
||||
}
|
||||
|
||||
return esValue[implSymbol]["localName"];
|
||||
}
|
||||
|
||||
get name() {
|
||||
const esValue = this !== null && this !== undefined ? this : globalObject;
|
||||
|
||||
if (!exports.is(esValue)) {
|
||||
throw new TypeError("Illegal invocation");
|
||||
}
|
||||
|
||||
return esValue[implSymbol]["name"];
|
||||
}
|
||||
|
||||
get value() {
|
||||
const esValue = this !== null && this !== undefined ? this : globalObject;
|
||||
|
||||
if (!exports.is(esValue)) {
|
||||
throw new TypeError("Illegal invocation");
|
||||
}
|
||||
|
||||
ceReactionsPreSteps_helpers_custom_elements(globalObject);
|
||||
try {
|
||||
return esValue[implSymbol]["value"];
|
||||
} finally {
|
||||
ceReactionsPostSteps_helpers_custom_elements(globalObject);
|
||||
}
|
||||
}
|
||||
|
||||
set value(V) {
|
||||
const esValue = this !== null && this !== undefined ? this : globalObject;
|
||||
|
||||
if (!exports.is(esValue)) {
|
||||
throw new TypeError("Illegal invocation");
|
||||
}
|
||||
|
||||
V = conversions["DOMString"](V, { context: "Failed to set the 'value' property on 'Attr': The provided value" });
|
||||
|
||||
ceReactionsPreSteps_helpers_custom_elements(globalObject);
|
||||
try {
|
||||
esValue[implSymbol]["value"] = V;
|
||||
} finally {
|
||||
ceReactionsPostSteps_helpers_custom_elements(globalObject);
|
||||
}
|
||||
}
|
||||
|
||||
get ownerElement() {
|
||||
const esValue = this !== null && this !== undefined ? this : globalObject;
|
||||
|
||||
if (!exports.is(esValue)) {
|
||||
throw new TypeError("Illegal invocation");
|
||||
}
|
||||
|
||||
return utils.tryWrapperForImpl(esValue[implSymbol]["ownerElement"]);
|
||||
}
|
||||
|
||||
get specified() {
|
||||
const esValue = this !== null && this !== undefined ? this : globalObject;
|
||||
|
||||
if (!exports.is(esValue)) {
|
||||
throw new TypeError("Illegal invocation");
|
||||
}
|
||||
|
||||
return esValue[implSymbol]["specified"];
|
||||
}
|
||||
}
|
||||
Object.defineProperties(Attr.prototype, {
|
||||
namespaceURI: { enumerable: true },
|
||||
prefix: { enumerable: true },
|
||||
localName: { enumerable: true },
|
||||
name: { enumerable: true },
|
||||
value: { enumerable: true },
|
||||
ownerElement: { enumerable: true },
|
||||
specified: { enumerable: true },
|
||||
[Symbol.toStringTag]: { value: "Attr", configurable: true }
|
||||
});
|
||||
if (globalObject[ctorRegistrySymbol] === undefined) {
|
||||
globalObject[ctorRegistrySymbol] = Object.create(null);
|
||||
}
|
||||
globalObject[ctorRegistrySymbol][interfaceName] = Attr;
|
||||
|
||||
Object.defineProperty(globalObject, interfaceName, {
|
||||
configurable: true,
|
||||
writable: true,
|
||||
value: Attr
|
||||
});
|
||||
};
|
||||
|
||||
const Impl = require("../attributes/Attr-impl.js");
|
||||
|
||||
202
node_modules/jsdom/lib/jsdom/living/generated/BarProp.js
generated
vendored
202
node_modules/jsdom/lib/jsdom/living/generated/BarProp.js
generated
vendored
@@ -3,114 +3,116 @@
|
||||
const conversions = require("webidl-conversions");
|
||||
const utils = require("./utils.js");
|
||||
|
||||
const impl = utils.implSymbol;
|
||||
const implSymbol = utils.implSymbol;
|
||||
const ctorRegistrySymbol = utils.ctorRegistrySymbol;
|
||||
|
||||
function BarProp() {
|
||||
throw new TypeError("Illegal constructor");
|
||||
const interfaceName = "BarProp";
|
||||
|
||||
exports.is = value => {
|
||||
return utils.isObject(value) && utils.hasOwn(value, implSymbol) && value[implSymbol] instanceof Impl.implementation;
|
||||
};
|
||||
exports.isImpl = value => {
|
||||
return utils.isObject(value) && value instanceof Impl.implementation;
|
||||
};
|
||||
exports.convert = (value, { context = "The provided value" } = {}) => {
|
||||
if (exports.is(value)) {
|
||||
return utils.implForWrapper(value);
|
||||
}
|
||||
throw new TypeError(`${context} is not of type 'BarProp'.`);
|
||||
};
|
||||
|
||||
function makeWrapper(globalObject) {
|
||||
if (globalObject[ctorRegistrySymbol] === undefined) {
|
||||
throw new Error("Internal error: invalid global object");
|
||||
}
|
||||
|
||||
const ctor = globalObject[ctorRegistrySymbol]["BarProp"];
|
||||
if (ctor === undefined) {
|
||||
throw new Error("Internal error: constructor BarProp is not installed on the passed global object");
|
||||
}
|
||||
|
||||
return Object.create(ctor.prototype);
|
||||
}
|
||||
|
||||
Object.defineProperty(BarProp, "prototype", {
|
||||
value: BarProp.prototype,
|
||||
writable: false,
|
||||
enumerable: false,
|
||||
configurable: false
|
||||
});
|
||||
exports.create = (globalObject, constructorArgs, privateData) => {
|
||||
const wrapper = makeWrapper(globalObject);
|
||||
return exports.setup(wrapper, globalObject, constructorArgs, privateData);
|
||||
};
|
||||
|
||||
Object.defineProperty(BarProp.prototype, "visible", {
|
||||
get() {
|
||||
if (!this || !module.exports.is(this)) {
|
||||
throw new TypeError("Illegal invocation");
|
||||
}
|
||||
exports.createImpl = (globalObject, constructorArgs, privateData) => {
|
||||
const wrapper = exports.create(globalObject, constructorArgs, privateData);
|
||||
return utils.implForWrapper(wrapper);
|
||||
};
|
||||
|
||||
return this[impl]["visible"];
|
||||
},
|
||||
exports._internalSetup = (wrapper, globalObject) => {};
|
||||
|
||||
enumerable: true,
|
||||
configurable: true
|
||||
});
|
||||
exports.setup = (wrapper, globalObject, constructorArgs = [], privateData = {}) => {
|
||||
privateData.wrapper = wrapper;
|
||||
|
||||
Object.defineProperty(BarProp.prototype, Symbol.toStringTag, {
|
||||
value: "BarProp",
|
||||
writable: false,
|
||||
enumerable: false,
|
||||
configurable: true
|
||||
});
|
||||
exports._internalSetup(wrapper, globalObject);
|
||||
Object.defineProperty(wrapper, implSymbol, {
|
||||
value: new Impl.implementation(globalObject, constructorArgs, privateData),
|
||||
configurable: true
|
||||
});
|
||||
|
||||
const iface = {
|
||||
// When an interface-module that implements this interface as a mixin is loaded, it will append its own `.is()`
|
||||
// method into this array. It allows objects that directly implements *those* interfaces to be recognized as
|
||||
// implementing this mixin interface.
|
||||
_mixedIntoPredicates: [],
|
||||
is(obj) {
|
||||
if (obj) {
|
||||
if (utils.hasOwn(obj, impl) && obj[impl] instanceof Impl.implementation) {
|
||||
return true;
|
||||
}
|
||||
for (const isMixedInto of module.exports._mixedIntoPredicates) {
|
||||
if (isMixedInto(obj)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
},
|
||||
isImpl(obj) {
|
||||
if (obj) {
|
||||
if (obj instanceof Impl.implementation) {
|
||||
return true;
|
||||
}
|
||||
|
||||
const wrapper = utils.wrapperForImpl(obj);
|
||||
for (const isMixedInto of module.exports._mixedIntoPredicates) {
|
||||
if (isMixedInto(wrapper)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
},
|
||||
convert(obj, { context = "The provided value" } = {}) {
|
||||
if (module.exports.is(obj)) {
|
||||
return utils.implForWrapper(obj);
|
||||
}
|
||||
throw new TypeError(`${context} is not of type 'BarProp'.`);
|
||||
},
|
||||
|
||||
create(constructorArgs, privateData) {
|
||||
let obj = Object.create(BarProp.prototype);
|
||||
obj = this.setup(obj, constructorArgs, privateData);
|
||||
return obj;
|
||||
},
|
||||
createImpl(constructorArgs, privateData) {
|
||||
let obj = Object.create(BarProp.prototype);
|
||||
obj = this.setup(obj, constructorArgs, privateData);
|
||||
return utils.implForWrapper(obj);
|
||||
},
|
||||
_internalSetup(obj) {},
|
||||
setup(obj, constructorArgs, privateData) {
|
||||
if (!privateData) privateData = {};
|
||||
|
||||
privateData.wrapper = obj;
|
||||
|
||||
this._internalSetup(obj);
|
||||
Object.defineProperty(obj, impl, {
|
||||
value: new Impl.implementation(constructorArgs, privateData),
|
||||
writable: false,
|
||||
enumerable: false,
|
||||
configurable: true
|
||||
});
|
||||
|
||||
obj[impl][utils.wrapperSymbol] = obj;
|
||||
if (Impl.init) {
|
||||
Impl.init(obj[impl], privateData);
|
||||
}
|
||||
return obj;
|
||||
},
|
||||
interface: BarProp,
|
||||
expose: {
|
||||
Window: { BarProp }
|
||||
wrapper[implSymbol][utils.wrapperSymbol] = wrapper;
|
||||
if (Impl.init) {
|
||||
Impl.init(wrapper[implSymbol]);
|
||||
}
|
||||
}; // iface
|
||||
module.exports = iface;
|
||||
return wrapper;
|
||||
};
|
||||
|
||||
exports.new = globalObject => {
|
||||
const wrapper = makeWrapper(globalObject);
|
||||
|
||||
exports._internalSetup(wrapper, globalObject);
|
||||
Object.defineProperty(wrapper, implSymbol, {
|
||||
value: Object.create(Impl.implementation.prototype),
|
||||
configurable: true
|
||||
});
|
||||
|
||||
wrapper[implSymbol][utils.wrapperSymbol] = wrapper;
|
||||
if (Impl.init) {
|
||||
Impl.init(wrapper[implSymbol]);
|
||||
}
|
||||
return wrapper[implSymbol];
|
||||
};
|
||||
|
||||
const exposed = new Set(["Window"]);
|
||||
|
||||
exports.install = (globalObject, globalNames) => {
|
||||
if (!globalNames.some(globalName => exposed.has(globalName))) {
|
||||
return;
|
||||
}
|
||||
class BarProp {
|
||||
constructor() {
|
||||
throw new TypeError("Illegal constructor");
|
||||
}
|
||||
|
||||
get visible() {
|
||||
const esValue = this !== null && this !== undefined ? this : globalObject;
|
||||
|
||||
if (!exports.is(esValue)) {
|
||||
throw new TypeError("Illegal invocation");
|
||||
}
|
||||
|
||||
return esValue[implSymbol]["visible"];
|
||||
}
|
||||
}
|
||||
Object.defineProperties(BarProp.prototype, {
|
||||
visible: { enumerable: true },
|
||||
[Symbol.toStringTag]: { value: "BarProp", configurable: true }
|
||||
});
|
||||
if (globalObject[ctorRegistrySymbol] === undefined) {
|
||||
globalObject[ctorRegistrySymbol] = Object.create(null);
|
||||
}
|
||||
globalObject[ctorRegistrySymbol][interfaceName] = BarProp;
|
||||
|
||||
Object.defineProperty(globalObject, interfaceName, {
|
||||
configurable: true,
|
||||
writable: true,
|
||||
value: BarProp
|
||||
});
|
||||
};
|
||||
|
||||
const Impl = require("../window/BarProp-impl.js");
|
||||
|
||||
15
node_modules/jsdom/lib/jsdom/living/generated/BinaryType.js
generated
vendored
15
node_modules/jsdom/lib/jsdom/living/generated/BinaryType.js
generated
vendored
@@ -1,13 +1,12 @@
|
||||
"use strict";
|
||||
|
||||
const enumerationValues = new Set(["blob", "arraybuffer"]);
|
||||
module.exports = {
|
||||
enumerationValues,
|
||||
convert(value, { context = "The provided value" } = {}) {
|
||||
const string = `${value}`;
|
||||
if (!enumerationValues.has(value)) {
|
||||
throw new TypeError(`${context} '${value}' is not a valid enumeration value for BinaryType`);
|
||||
}
|
||||
return string;
|
||||
exports.enumerationValues = enumerationValues;
|
||||
|
||||
exports.convert = function convert(value, { context = "The provided value" } = {}) {
|
||||
const string = `${value}`;
|
||||
if (!enumerationValues.has(string)) {
|
||||
throw new TypeError(`${context} '${string}' is not a valid enumeration value for BinaryType`);
|
||||
}
|
||||
return string;
|
||||
};
|
||||
|
||||
375
node_modules/jsdom/lib/jsdom/living/generated/Blob.js
generated
vendored
375
node_modules/jsdom/lib/jsdom/living/generated/Blob.js
generated
vendored
@@ -3,201 +3,196 @@
|
||||
const conversions = require("webidl-conversions");
|
||||
const utils = require("./utils.js");
|
||||
|
||||
const convertBlobPropertyBag = require("./BlobPropertyBag.js").convert;
|
||||
const impl = utils.implSymbol;
|
||||
const BlobPropertyBag = require("./BlobPropertyBag.js");
|
||||
const implSymbol = utils.implSymbol;
|
||||
const ctorRegistrySymbol = utils.ctorRegistrySymbol;
|
||||
|
||||
function Blob() {
|
||||
if (new.target === undefined) {
|
||||
throw new TypeError(
|
||||
"Failed to construct 'Blob'. Please use the 'new' operator; this constructor " + "cannot be called as a function."
|
||||
);
|
||||
}
|
||||
const args = [];
|
||||
{
|
||||
let curArg = arguments[0];
|
||||
if (curArg !== undefined) {
|
||||
if (!utils.isObject(curArg)) {
|
||||
throw new TypeError("Failed to construct 'Blob': parameter 1" + " is not an iterable object.");
|
||||
} else {
|
||||
const V = [];
|
||||
const tmp = curArg;
|
||||
for (let nextItem of tmp) {
|
||||
if (module.exports.is(nextItem)) {
|
||||
nextItem = utils.implForWrapper(nextItem);
|
||||
} else if (nextItem instanceof ArrayBuffer) {
|
||||
} else if (ArrayBuffer.isView(nextItem)) {
|
||||
} else {
|
||||
nextItem = conversions["USVString"](nextItem, {
|
||||
context: "Failed to construct 'Blob': parameter 1" + "'s element"
|
||||
});
|
||||
}
|
||||
V.push(nextItem);
|
||||
}
|
||||
curArg = V;
|
||||
}
|
||||
}
|
||||
args.push(curArg);
|
||||
}
|
||||
{
|
||||
let curArg = arguments[1];
|
||||
curArg = convertBlobPropertyBag(curArg, { context: "Failed to construct 'Blob': parameter 2" });
|
||||
args.push(curArg);
|
||||
}
|
||||
const interfaceName = "Blob";
|
||||
|
||||
iface.setup(this, args);
|
||||
}
|
||||
|
||||
Object.defineProperty(Blob, "prototype", {
|
||||
value: Blob.prototype,
|
||||
writable: false,
|
||||
enumerable: false,
|
||||
configurable: false
|
||||
});
|
||||
|
||||
Blob.prototype.slice = function slice() {
|
||||
if (!this || !module.exports.is(this)) {
|
||||
throw new TypeError("Illegal invocation");
|
||||
exports.is = value => {
|
||||
return utils.isObject(value) && utils.hasOwn(value, implSymbol) && value[implSymbol] instanceof Impl.implementation;
|
||||
};
|
||||
exports.isImpl = value => {
|
||||
return utils.isObject(value) && value instanceof Impl.implementation;
|
||||
};
|
||||
exports.convert = (value, { context = "The provided value" } = {}) => {
|
||||
if (exports.is(value)) {
|
||||
return utils.implForWrapper(value);
|
||||
}
|
||||
const args = [];
|
||||
{
|
||||
let curArg = arguments[0];
|
||||
if (curArg !== undefined) {
|
||||
curArg = conversions["long long"](curArg, {
|
||||
context: "Failed to execute 'slice' on 'Blob': parameter 1",
|
||||
clamp: true
|
||||
});
|
||||
}
|
||||
args.push(curArg);
|
||||
}
|
||||
{
|
||||
let curArg = arguments[1];
|
||||
if (curArg !== undefined) {
|
||||
curArg = conversions["long long"](curArg, {
|
||||
context: "Failed to execute 'slice' on 'Blob': parameter 2",
|
||||
clamp: true
|
||||
});
|
||||
}
|
||||
args.push(curArg);
|
||||
}
|
||||
{
|
||||
let curArg = arguments[2];
|
||||
if (curArg !== undefined) {
|
||||
curArg = conversions["DOMString"](curArg, { context: "Failed to execute 'slice' on 'Blob': parameter 3" });
|
||||
}
|
||||
args.push(curArg);
|
||||
}
|
||||
return utils.tryWrapperForImpl(this[impl].slice(...args));
|
||||
throw new TypeError(`${context} is not of type 'Blob'.`);
|
||||
};
|
||||
|
||||
Object.defineProperty(Blob.prototype, "size", {
|
||||
get() {
|
||||
if (!this || !module.exports.is(this)) {
|
||||
throw new TypeError("Illegal invocation");
|
||||
}
|
||||
|
||||
return this[impl]["size"];
|
||||
},
|
||||
|
||||
enumerable: true,
|
||||
configurable: true
|
||||
});
|
||||
|
||||
Object.defineProperty(Blob.prototype, "type", {
|
||||
get() {
|
||||
if (!this || !module.exports.is(this)) {
|
||||
throw new TypeError("Illegal invocation");
|
||||
}
|
||||
|
||||
return this[impl]["type"];
|
||||
},
|
||||
|
||||
enumerable: true,
|
||||
configurable: true
|
||||
});
|
||||
|
||||
Object.defineProperty(Blob.prototype, Symbol.toStringTag, {
|
||||
value: "Blob",
|
||||
writable: false,
|
||||
enumerable: false,
|
||||
configurable: true
|
||||
});
|
||||
|
||||
const iface = {
|
||||
// When an interface-module that implements this interface as a mixin is loaded, it will append its own `.is()`
|
||||
// method into this array. It allows objects that directly implements *those* interfaces to be recognized as
|
||||
// implementing this mixin interface.
|
||||
_mixedIntoPredicates: [],
|
||||
is(obj) {
|
||||
if (obj) {
|
||||
if (utils.hasOwn(obj, impl) && obj[impl] instanceof Impl.implementation) {
|
||||
return true;
|
||||
}
|
||||
for (const isMixedInto of module.exports._mixedIntoPredicates) {
|
||||
if (isMixedInto(obj)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
},
|
||||
isImpl(obj) {
|
||||
if (obj) {
|
||||
if (obj instanceof Impl.implementation) {
|
||||
return true;
|
||||
}
|
||||
|
||||
const wrapper = utils.wrapperForImpl(obj);
|
||||
for (const isMixedInto of module.exports._mixedIntoPredicates) {
|
||||
if (isMixedInto(wrapper)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
},
|
||||
convert(obj, { context = "The provided value" } = {}) {
|
||||
if (module.exports.is(obj)) {
|
||||
return utils.implForWrapper(obj);
|
||||
}
|
||||
throw new TypeError(`${context} is not of type 'Blob'.`);
|
||||
},
|
||||
|
||||
create(constructorArgs, privateData) {
|
||||
let obj = Object.create(Blob.prototype);
|
||||
obj = this.setup(obj, constructorArgs, privateData);
|
||||
return obj;
|
||||
},
|
||||
createImpl(constructorArgs, privateData) {
|
||||
let obj = Object.create(Blob.prototype);
|
||||
obj = this.setup(obj, constructorArgs, privateData);
|
||||
return utils.implForWrapper(obj);
|
||||
},
|
||||
_internalSetup(obj) {},
|
||||
setup(obj, constructorArgs, privateData) {
|
||||
if (!privateData) privateData = {};
|
||||
|
||||
privateData.wrapper = obj;
|
||||
|
||||
this._internalSetup(obj);
|
||||
Object.defineProperty(obj, impl, {
|
||||
value: new Impl.implementation(constructorArgs, privateData),
|
||||
writable: false,
|
||||
enumerable: false,
|
||||
configurable: true
|
||||
});
|
||||
|
||||
obj[impl][utils.wrapperSymbol] = obj;
|
||||
if (Impl.init) {
|
||||
Impl.init(obj[impl], privateData);
|
||||
}
|
||||
return obj;
|
||||
},
|
||||
interface: Blob,
|
||||
expose: {
|
||||
Window: { Blob },
|
||||
Worker: { Blob }
|
||||
function makeWrapper(globalObject) {
|
||||
if (globalObject[ctorRegistrySymbol] === undefined) {
|
||||
throw new Error("Internal error: invalid global object");
|
||||
}
|
||||
}; // iface
|
||||
module.exports = iface;
|
||||
|
||||
const ctor = globalObject[ctorRegistrySymbol]["Blob"];
|
||||
if (ctor === undefined) {
|
||||
throw new Error("Internal error: constructor Blob is not installed on the passed global object");
|
||||
}
|
||||
|
||||
return Object.create(ctor.prototype);
|
||||
}
|
||||
|
||||
exports.create = (globalObject, constructorArgs, privateData) => {
|
||||
const wrapper = makeWrapper(globalObject);
|
||||
return exports.setup(wrapper, globalObject, constructorArgs, privateData);
|
||||
};
|
||||
|
||||
exports.createImpl = (globalObject, constructorArgs, privateData) => {
|
||||
const wrapper = exports.create(globalObject, constructorArgs, privateData);
|
||||
return utils.implForWrapper(wrapper);
|
||||
};
|
||||
|
||||
exports._internalSetup = (wrapper, globalObject) => {};
|
||||
|
||||
exports.setup = (wrapper, globalObject, constructorArgs = [], privateData = {}) => {
|
||||
privateData.wrapper = wrapper;
|
||||
|
||||
exports._internalSetup(wrapper, globalObject);
|
||||
Object.defineProperty(wrapper, implSymbol, {
|
||||
value: new Impl.implementation(globalObject, constructorArgs, privateData),
|
||||
configurable: true
|
||||
});
|
||||
|
||||
wrapper[implSymbol][utils.wrapperSymbol] = wrapper;
|
||||
if (Impl.init) {
|
||||
Impl.init(wrapper[implSymbol]);
|
||||
}
|
||||
return wrapper;
|
||||
};
|
||||
|
||||
exports.new = globalObject => {
|
||||
const wrapper = makeWrapper(globalObject);
|
||||
|
||||
exports._internalSetup(wrapper, globalObject);
|
||||
Object.defineProperty(wrapper, implSymbol, {
|
||||
value: Object.create(Impl.implementation.prototype),
|
||||
configurable: true
|
||||
});
|
||||
|
||||
wrapper[implSymbol][utils.wrapperSymbol] = wrapper;
|
||||
if (Impl.init) {
|
||||
Impl.init(wrapper[implSymbol]);
|
||||
}
|
||||
return wrapper[implSymbol];
|
||||
};
|
||||
|
||||
const exposed = new Set(["Window", "Worker"]);
|
||||
|
||||
exports.install = (globalObject, globalNames) => {
|
||||
if (!globalNames.some(globalName => exposed.has(globalName))) {
|
||||
return;
|
||||
}
|
||||
class Blob {
|
||||
constructor() {
|
||||
const args = [];
|
||||
{
|
||||
let curArg = arguments[0];
|
||||
if (curArg !== undefined) {
|
||||
if (!utils.isObject(curArg)) {
|
||||
throw new TypeError("Failed to construct 'Blob': parameter 1" + " is not an iterable object.");
|
||||
} else {
|
||||
const V = [];
|
||||
const tmp = curArg;
|
||||
for (let nextItem of tmp) {
|
||||
if (exports.is(nextItem)) {
|
||||
nextItem = utils.implForWrapper(nextItem);
|
||||
} else if (utils.isArrayBuffer(nextItem)) {
|
||||
} else if (ArrayBuffer.isView(nextItem)) {
|
||||
} else {
|
||||
nextItem = conversions["USVString"](nextItem, {
|
||||
context: "Failed to construct 'Blob': parameter 1" + "'s element"
|
||||
});
|
||||
}
|
||||
V.push(nextItem);
|
||||
}
|
||||
curArg = V;
|
||||
}
|
||||
}
|
||||
args.push(curArg);
|
||||
}
|
||||
{
|
||||
let curArg = arguments[1];
|
||||
curArg = BlobPropertyBag.convert(curArg, { context: "Failed to construct 'Blob': parameter 2" });
|
||||
args.push(curArg);
|
||||
}
|
||||
return exports.setup(Object.create(new.target.prototype), globalObject, args);
|
||||
}
|
||||
|
||||
slice() {
|
||||
const esValue = this !== null && this !== undefined ? this : globalObject;
|
||||
if (!exports.is(esValue)) {
|
||||
throw new TypeError("Illegal invocation");
|
||||
}
|
||||
const args = [];
|
||||
{
|
||||
let curArg = arguments[0];
|
||||
if (curArg !== undefined) {
|
||||
curArg = conversions["long long"](curArg, {
|
||||
context: "Failed to execute 'slice' on 'Blob': parameter 1",
|
||||
clamp: true
|
||||
});
|
||||
}
|
||||
args.push(curArg);
|
||||
}
|
||||
{
|
||||
let curArg = arguments[1];
|
||||
if (curArg !== undefined) {
|
||||
curArg = conversions["long long"](curArg, {
|
||||
context: "Failed to execute 'slice' on 'Blob': parameter 2",
|
||||
clamp: true
|
||||
});
|
||||
}
|
||||
args.push(curArg);
|
||||
}
|
||||
{
|
||||
let curArg = arguments[2];
|
||||
if (curArg !== undefined) {
|
||||
curArg = conversions["DOMString"](curArg, { context: "Failed to execute 'slice' on 'Blob': parameter 3" });
|
||||
}
|
||||
args.push(curArg);
|
||||
}
|
||||
return utils.tryWrapperForImpl(esValue[implSymbol].slice(...args));
|
||||
}
|
||||
|
||||
get size() {
|
||||
const esValue = this !== null && this !== undefined ? this : globalObject;
|
||||
|
||||
if (!exports.is(esValue)) {
|
||||
throw new TypeError("Illegal invocation");
|
||||
}
|
||||
|
||||
return esValue[implSymbol]["size"];
|
||||
}
|
||||
|
||||
get type() {
|
||||
const esValue = this !== null && this !== undefined ? this : globalObject;
|
||||
|
||||
if (!exports.is(esValue)) {
|
||||
throw new TypeError("Illegal invocation");
|
||||
}
|
||||
|
||||
return esValue[implSymbol]["type"];
|
||||
}
|
||||
}
|
||||
Object.defineProperties(Blob.prototype, {
|
||||
slice: { enumerable: true },
|
||||
size: { enumerable: true },
|
||||
type: { enumerable: true },
|
||||
[Symbol.toStringTag]: { value: "Blob", configurable: true }
|
||||
});
|
||||
if (globalObject[ctorRegistrySymbol] === undefined) {
|
||||
globalObject[ctorRegistrySymbol] = Object.create(null);
|
||||
}
|
||||
globalObject[ctorRegistrySymbol][interfaceName] = Blob;
|
||||
|
||||
Object.defineProperty(globalObject, interfaceName, {
|
||||
configurable: true,
|
||||
writable: true,
|
||||
value: Blob
|
||||
});
|
||||
};
|
||||
|
||||
const Impl = require("../file-api/Blob-impl.js");
|
||||
|
||||
60
node_modules/jsdom/lib/jsdom/living/generated/BlobPropertyBag.js
generated
vendored
60
node_modules/jsdom/lib/jsdom/living/generated/BlobPropertyBag.js
generated
vendored
@@ -3,42 +3,40 @@
|
||||
const conversions = require("webidl-conversions");
|
||||
const utils = require("./utils.js");
|
||||
|
||||
const convertEndingType = require("./EndingType.js").convert;
|
||||
const EndingType = require("./EndingType.js");
|
||||
|
||||
module.exports = {
|
||||
convertInherit(obj, ret, { context = "The provided value" } = {}) {
|
||||
{
|
||||
const key = "endings";
|
||||
let value = obj === undefined || obj === null ? undefined : obj[key];
|
||||
if (value !== undefined) {
|
||||
value = convertEndingType(value, { context: context + " has member endings that" });
|
||||
exports._convertInherit = (obj, ret, { context = "The provided value" } = {}) => {
|
||||
{
|
||||
const key = "endings";
|
||||
let value = obj === undefined || obj === null ? undefined : obj[key];
|
||||
if (value !== undefined) {
|
||||
value = EndingType.convert(value, { context: context + " has member 'endings' that" });
|
||||
|
||||
ret[key] = value;
|
||||
} else {
|
||||
ret[key] = "transparent";
|
||||
}
|
||||
ret[key] = value;
|
||||
} else {
|
||||
ret[key] = "transparent";
|
||||
}
|
||||
}
|
||||
|
||||
{
|
||||
const key = "type";
|
||||
let value = obj === undefined || obj === null ? undefined : obj[key];
|
||||
if (value !== undefined) {
|
||||
value = conversions["DOMString"](value, { context: context + " has member type that" });
|
||||
{
|
||||
const key = "type";
|
||||
let value = obj === undefined || obj === null ? undefined : obj[key];
|
||||
if (value !== undefined) {
|
||||
value = conversions["DOMString"](value, { context: context + " has member 'type' that" });
|
||||
|
||||
ret[key] = value;
|
||||
} else {
|
||||
ret[key] = "";
|
||||
}
|
||||
ret[key] = value;
|
||||
} else {
|
||||
ret[key] = "";
|
||||
}
|
||||
},
|
||||
|
||||
convert(obj, { context = "The provided value" } = {}) {
|
||||
if (obj !== undefined && typeof obj !== "object" && typeof obj !== "function") {
|
||||
throw new TypeError(`${context} is not an object.`);
|
||||
}
|
||||
|
||||
const ret = Object.create(null);
|
||||
module.exports.convertInherit(obj, ret, { context });
|
||||
return ret;
|
||||
}
|
||||
};
|
||||
|
||||
exports.convert = function convert(obj, { context = "The provided value" } = {}) {
|
||||
if (obj !== undefined && typeof obj !== "object" && typeof obj !== "function") {
|
||||
throw new TypeError(`${context} is not an object.`);
|
||||
}
|
||||
|
||||
const ret = Object.create(null);
|
||||
exports._convertInherit(obj, ret, { context });
|
||||
return ret;
|
||||
};
|
||||
|
||||
189
node_modules/jsdom/lib/jsdom/living/generated/CDATASection.js
generated
vendored
189
node_modules/jsdom/lib/jsdom/living/generated/CDATASection.js
generated
vendored
@@ -3,107 +3,112 @@
|
||||
const conversions = require("webidl-conversions");
|
||||
const utils = require("./utils.js");
|
||||
|
||||
const impl = utils.implSymbol;
|
||||
const implSymbol = utils.implSymbol;
|
||||
const ctorRegistrySymbol = utils.ctorRegistrySymbol;
|
||||
const Text = require("./Text.js");
|
||||
|
||||
function CDATASection() {
|
||||
throw new TypeError("Illegal constructor");
|
||||
const interfaceName = "CDATASection";
|
||||
|
||||
exports.is = value => {
|
||||
return utils.isObject(value) && utils.hasOwn(value, implSymbol) && value[implSymbol] instanceof Impl.implementation;
|
||||
};
|
||||
exports.isImpl = value => {
|
||||
return utils.isObject(value) && value instanceof Impl.implementation;
|
||||
};
|
||||
exports.convert = (value, { context = "The provided value" } = {}) => {
|
||||
if (exports.is(value)) {
|
||||
return utils.implForWrapper(value);
|
||||
}
|
||||
throw new TypeError(`${context} is not of type 'CDATASection'.`);
|
||||
};
|
||||
|
||||
function makeWrapper(globalObject) {
|
||||
if (globalObject[ctorRegistrySymbol] === undefined) {
|
||||
throw new Error("Internal error: invalid global object");
|
||||
}
|
||||
|
||||
const ctor = globalObject[ctorRegistrySymbol]["CDATASection"];
|
||||
if (ctor === undefined) {
|
||||
throw new Error("Internal error: constructor CDATASection is not installed on the passed global object");
|
||||
}
|
||||
|
||||
return Object.create(ctor.prototype);
|
||||
}
|
||||
|
||||
Object.setPrototypeOf(CDATASection.prototype, Text.interface.prototype);
|
||||
Object.setPrototypeOf(CDATASection, Text.interface);
|
||||
exports.create = (globalObject, constructorArgs, privateData) => {
|
||||
const wrapper = makeWrapper(globalObject);
|
||||
return exports.setup(wrapper, globalObject, constructorArgs, privateData);
|
||||
};
|
||||
|
||||
Object.defineProperty(CDATASection, "prototype", {
|
||||
value: CDATASection.prototype,
|
||||
writable: false,
|
||||
enumerable: false,
|
||||
configurable: false
|
||||
});
|
||||
exports.createImpl = (globalObject, constructorArgs, privateData) => {
|
||||
const wrapper = exports.create(globalObject, constructorArgs, privateData);
|
||||
return utils.implForWrapper(wrapper);
|
||||
};
|
||||
|
||||
Object.defineProperty(CDATASection.prototype, Symbol.toStringTag, {
|
||||
value: "CDATASection",
|
||||
writable: false,
|
||||
enumerable: false,
|
||||
configurable: true
|
||||
});
|
||||
exports._internalSetup = (wrapper, globalObject) => {
|
||||
Text._internalSetup(wrapper, globalObject);
|
||||
};
|
||||
|
||||
const iface = {
|
||||
// When an interface-module that implements this interface as a mixin is loaded, it will append its own `.is()`
|
||||
// method into this array. It allows objects that directly implements *those* interfaces to be recognized as
|
||||
// implementing this mixin interface.
|
||||
_mixedIntoPredicates: [],
|
||||
is(obj) {
|
||||
if (obj) {
|
||||
if (utils.hasOwn(obj, impl) && obj[impl] instanceof Impl.implementation) {
|
||||
return true;
|
||||
}
|
||||
for (const isMixedInto of module.exports._mixedIntoPredicates) {
|
||||
if (isMixedInto(obj)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
},
|
||||
isImpl(obj) {
|
||||
if (obj) {
|
||||
if (obj instanceof Impl.implementation) {
|
||||
return true;
|
||||
}
|
||||
exports.setup = (wrapper, globalObject, constructorArgs = [], privateData = {}) => {
|
||||
privateData.wrapper = wrapper;
|
||||
|
||||
const wrapper = utils.wrapperForImpl(obj);
|
||||
for (const isMixedInto of module.exports._mixedIntoPredicates) {
|
||||
if (isMixedInto(wrapper)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
},
|
||||
convert(obj, { context = "The provided value" } = {}) {
|
||||
if (module.exports.is(obj)) {
|
||||
return utils.implForWrapper(obj);
|
||||
}
|
||||
throw new TypeError(`${context} is not of type 'CDATASection'.`);
|
||||
},
|
||||
exports._internalSetup(wrapper, globalObject);
|
||||
Object.defineProperty(wrapper, implSymbol, {
|
||||
value: new Impl.implementation(globalObject, constructorArgs, privateData),
|
||||
configurable: true
|
||||
});
|
||||
|
||||
create(constructorArgs, privateData) {
|
||||
let obj = Object.create(CDATASection.prototype);
|
||||
obj = this.setup(obj, constructorArgs, privateData);
|
||||
return obj;
|
||||
},
|
||||
createImpl(constructorArgs, privateData) {
|
||||
let obj = Object.create(CDATASection.prototype);
|
||||
obj = this.setup(obj, constructorArgs, privateData);
|
||||
return utils.implForWrapper(obj);
|
||||
},
|
||||
_internalSetup(obj) {
|
||||
Text._internalSetup(obj);
|
||||
},
|
||||
setup(obj, constructorArgs, privateData) {
|
||||
if (!privateData) privateData = {};
|
||||
|
||||
privateData.wrapper = obj;
|
||||
|
||||
this._internalSetup(obj);
|
||||
Object.defineProperty(obj, impl, {
|
||||
value: new Impl.implementation(constructorArgs, privateData),
|
||||
writable: false,
|
||||
enumerable: false,
|
||||
configurable: true
|
||||
});
|
||||
|
||||
obj[impl][utils.wrapperSymbol] = obj;
|
||||
if (Impl.init) {
|
||||
Impl.init(obj[impl], privateData);
|
||||
}
|
||||
return obj;
|
||||
},
|
||||
interface: CDATASection,
|
||||
expose: {
|
||||
Window: { CDATASection }
|
||||
wrapper[implSymbol][utils.wrapperSymbol] = wrapper;
|
||||
if (Impl.init) {
|
||||
Impl.init(wrapper[implSymbol]);
|
||||
}
|
||||
}; // iface
|
||||
module.exports = iface;
|
||||
return wrapper;
|
||||
};
|
||||
|
||||
exports.new = globalObject => {
|
||||
const wrapper = makeWrapper(globalObject);
|
||||
|
||||
exports._internalSetup(wrapper, globalObject);
|
||||
Object.defineProperty(wrapper, implSymbol, {
|
||||
value: Object.create(Impl.implementation.prototype),
|
||||
configurable: true
|
||||
});
|
||||
|
||||
wrapper[implSymbol][utils.wrapperSymbol] = wrapper;
|
||||
if (Impl.init) {
|
||||
Impl.init(wrapper[implSymbol]);
|
||||
}
|
||||
return wrapper[implSymbol];
|
||||
};
|
||||
|
||||
const exposed = new Set(["Window"]);
|
||||
|
||||
exports.install = (globalObject, globalNames) => {
|
||||
if (!globalNames.some(globalName => exposed.has(globalName))) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (globalObject.Text === undefined) {
|
||||
throw new Error("Internal error: attempting to evaluate CDATASection before Text");
|
||||
}
|
||||
class CDATASection extends globalObject.Text {
|
||||
constructor() {
|
||||
throw new TypeError("Illegal constructor");
|
||||
}
|
||||
}
|
||||
Object.defineProperties(CDATASection.prototype, {
|
||||
[Symbol.toStringTag]: { value: "CDATASection", configurable: true }
|
||||
});
|
||||
if (globalObject[ctorRegistrySymbol] === undefined) {
|
||||
globalObject[ctorRegistrySymbol] = Object.create(null);
|
||||
}
|
||||
globalObject[ctorRegistrySymbol][interfaceName] = CDATASection;
|
||||
|
||||
Object.defineProperty(globalObject, interfaceName, {
|
||||
configurable: true,
|
||||
writable: true,
|
||||
value: CDATASection
|
||||
});
|
||||
};
|
||||
|
||||
const Impl = require("../nodes/CDATASection-impl.js");
|
||||
|
||||
15
node_modules/jsdom/lib/jsdom/living/generated/CanPlayTypeResult.js
generated
vendored
15
node_modules/jsdom/lib/jsdom/living/generated/CanPlayTypeResult.js
generated
vendored
@@ -1,13 +1,12 @@
|
||||
"use strict";
|
||||
|
||||
const enumerationValues = new Set(["", "maybe", "probably"]);
|
||||
module.exports = {
|
||||
enumerationValues,
|
||||
convert(value, { context = "The provided value" } = {}) {
|
||||
const string = `${value}`;
|
||||
if (!enumerationValues.has(value)) {
|
||||
throw new TypeError(`${context} '${value}' is not a valid enumeration value for CanPlayTypeResult`);
|
||||
}
|
||||
return string;
|
||||
exports.enumerationValues = enumerationValues;
|
||||
|
||||
exports.convert = function convert(value, { context = "The provided value" } = {}) {
|
||||
const string = `${value}`;
|
||||
if (!enumerationValues.has(string)) {
|
||||
throw new TypeError(`${context} '${string}' is not a valid enumeration value for CanPlayTypeResult`);
|
||||
}
|
||||
return string;
|
||||
};
|
||||
|
||||
736
node_modules/jsdom/lib/jsdom/living/generated/CharacterData.js
generated
vendored
736
node_modules/jsdom/lib/jsdom/living/generated/CharacterData.js
generated
vendored
@@ -3,394 +3,430 @@
|
||||
const conversions = require("webidl-conversions");
|
||||
const utils = require("./utils.js");
|
||||
|
||||
const isNode = require("./Node.js").is;
|
||||
const impl = utils.implSymbol;
|
||||
const Node = require("./Node.js");
|
||||
const ChildNode = require("./ChildNode.js");
|
||||
const NonDocumentTypeChildNode = require("./NonDocumentTypeChildNode.js");
|
||||
const ceReactionsPreSteps_helpers_custom_elements = require("../helpers/custom-elements.js").ceReactionsPreSteps;
|
||||
const ceReactionsPostSteps_helpers_custom_elements = require("../helpers/custom-elements.js").ceReactionsPostSteps;
|
||||
const implSymbol = utils.implSymbol;
|
||||
const ctorRegistrySymbol = utils.ctorRegistrySymbol;
|
||||
|
||||
function CharacterData() {
|
||||
throw new TypeError("Illegal constructor");
|
||||
const interfaceName = "CharacterData";
|
||||
|
||||
exports.is = value => {
|
||||
return utils.isObject(value) && utils.hasOwn(value, implSymbol) && value[implSymbol] instanceof Impl.implementation;
|
||||
};
|
||||
exports.isImpl = value => {
|
||||
return utils.isObject(value) && value instanceof Impl.implementation;
|
||||
};
|
||||
exports.convert = (value, { context = "The provided value" } = {}) => {
|
||||
if (exports.is(value)) {
|
||||
return utils.implForWrapper(value);
|
||||
}
|
||||
throw new TypeError(`${context} is not of type 'CharacterData'.`);
|
||||
};
|
||||
|
||||
function makeWrapper(globalObject) {
|
||||
if (globalObject[ctorRegistrySymbol] === undefined) {
|
||||
throw new Error("Internal error: invalid global object");
|
||||
}
|
||||
|
||||
const ctor = globalObject[ctorRegistrySymbol]["CharacterData"];
|
||||
if (ctor === undefined) {
|
||||
throw new Error("Internal error: constructor CharacterData is not installed on the passed global object");
|
||||
}
|
||||
|
||||
return Object.create(ctor.prototype);
|
||||
}
|
||||
|
||||
Object.setPrototypeOf(CharacterData.prototype, Node.interface.prototype);
|
||||
Object.setPrototypeOf(CharacterData, Node.interface);
|
||||
|
||||
Object.defineProperty(CharacterData, "prototype", {
|
||||
value: CharacterData.prototype,
|
||||
writable: false,
|
||||
enumerable: false,
|
||||
configurable: false
|
||||
});
|
||||
|
||||
CharacterData.prototype.substringData = function substringData(offset, count) {
|
||||
if (!this || !module.exports.is(this)) {
|
||||
throw new TypeError("Illegal invocation");
|
||||
}
|
||||
|
||||
if (arguments.length < 2) {
|
||||
throw new TypeError(
|
||||
"Failed to execute 'substringData' on 'CharacterData': 2 arguments required, but only " +
|
||||
arguments.length +
|
||||
" present."
|
||||
);
|
||||
}
|
||||
const args = [];
|
||||
{
|
||||
let curArg = arguments[0];
|
||||
curArg = conversions["unsigned long"](curArg, {
|
||||
context: "Failed to execute 'substringData' on 'CharacterData': parameter 1"
|
||||
});
|
||||
args.push(curArg);
|
||||
}
|
||||
{
|
||||
let curArg = arguments[1];
|
||||
curArg = conversions["unsigned long"](curArg, {
|
||||
context: "Failed to execute 'substringData' on 'CharacterData': parameter 2"
|
||||
});
|
||||
args.push(curArg);
|
||||
}
|
||||
return this[impl].substringData(...args);
|
||||
exports.create = (globalObject, constructorArgs, privateData) => {
|
||||
const wrapper = makeWrapper(globalObject);
|
||||
return exports.setup(wrapper, globalObject, constructorArgs, privateData);
|
||||
};
|
||||
|
||||
CharacterData.prototype.appendData = function appendData(data) {
|
||||
if (!this || !module.exports.is(this)) {
|
||||
throw new TypeError("Illegal invocation");
|
||||
}
|
||||
|
||||
if (arguments.length < 1) {
|
||||
throw new TypeError(
|
||||
"Failed to execute 'appendData' on 'CharacterData': 1 argument required, but only " +
|
||||
arguments.length +
|
||||
" present."
|
||||
);
|
||||
}
|
||||
const args = [];
|
||||
{
|
||||
let curArg = arguments[0];
|
||||
curArg = conversions["DOMString"](curArg, {
|
||||
context: "Failed to execute 'appendData' on 'CharacterData': parameter 1"
|
||||
});
|
||||
args.push(curArg);
|
||||
}
|
||||
return this[impl].appendData(...args);
|
||||
exports.createImpl = (globalObject, constructorArgs, privateData) => {
|
||||
const wrapper = exports.create(globalObject, constructorArgs, privateData);
|
||||
return utils.implForWrapper(wrapper);
|
||||
};
|
||||
|
||||
CharacterData.prototype.insertData = function insertData(offset, data) {
|
||||
if (!this || !module.exports.is(this)) {
|
||||
throw new TypeError("Illegal invocation");
|
||||
}
|
||||
|
||||
if (arguments.length < 2) {
|
||||
throw new TypeError(
|
||||
"Failed to execute 'insertData' on 'CharacterData': 2 arguments required, but only " +
|
||||
arguments.length +
|
||||
" present."
|
||||
);
|
||||
}
|
||||
const args = [];
|
||||
{
|
||||
let curArg = arguments[0];
|
||||
curArg = conversions["unsigned long"](curArg, {
|
||||
context: "Failed to execute 'insertData' on 'CharacterData': parameter 1"
|
||||
});
|
||||
args.push(curArg);
|
||||
}
|
||||
{
|
||||
let curArg = arguments[1];
|
||||
curArg = conversions["DOMString"](curArg, {
|
||||
context: "Failed to execute 'insertData' on 'CharacterData': parameter 2"
|
||||
});
|
||||
args.push(curArg);
|
||||
}
|
||||
return this[impl].insertData(...args);
|
||||
exports._internalSetup = (wrapper, globalObject) => {
|
||||
Node._internalSetup(wrapper, globalObject);
|
||||
};
|
||||
|
||||
CharacterData.prototype.deleteData = function deleteData(offset, count) {
|
||||
if (!this || !module.exports.is(this)) {
|
||||
throw new TypeError("Illegal invocation");
|
||||
}
|
||||
exports.setup = (wrapper, globalObject, constructorArgs = [], privateData = {}) => {
|
||||
privateData.wrapper = wrapper;
|
||||
|
||||
if (arguments.length < 2) {
|
||||
throw new TypeError(
|
||||
"Failed to execute 'deleteData' on 'CharacterData': 2 arguments required, but only " +
|
||||
arguments.length +
|
||||
" present."
|
||||
);
|
||||
exports._internalSetup(wrapper, globalObject);
|
||||
Object.defineProperty(wrapper, implSymbol, {
|
||||
value: new Impl.implementation(globalObject, constructorArgs, privateData),
|
||||
configurable: true
|
||||
});
|
||||
|
||||
wrapper[implSymbol][utils.wrapperSymbol] = wrapper;
|
||||
if (Impl.init) {
|
||||
Impl.init(wrapper[implSymbol]);
|
||||
}
|
||||
const args = [];
|
||||
{
|
||||
let curArg = arguments[0];
|
||||
curArg = conversions["unsigned long"](curArg, {
|
||||
context: "Failed to execute 'deleteData' on 'CharacterData': parameter 1"
|
||||
});
|
||||
args.push(curArg);
|
||||
}
|
||||
{
|
||||
let curArg = arguments[1];
|
||||
curArg = conversions["unsigned long"](curArg, {
|
||||
context: "Failed to execute 'deleteData' on 'CharacterData': parameter 2"
|
||||
});
|
||||
args.push(curArg);
|
||||
}
|
||||
return this[impl].deleteData(...args);
|
||||
return wrapper;
|
||||
};
|
||||
|
||||
CharacterData.prototype.replaceData = function replaceData(offset, count, data) {
|
||||
if (!this || !module.exports.is(this)) {
|
||||
throw new TypeError("Illegal invocation");
|
||||
}
|
||||
exports.new = globalObject => {
|
||||
const wrapper = makeWrapper(globalObject);
|
||||
|
||||
if (arguments.length < 3) {
|
||||
throw new TypeError(
|
||||
"Failed to execute 'replaceData' on 'CharacterData': 3 arguments required, but only " +
|
||||
arguments.length +
|
||||
" present."
|
||||
);
|
||||
exports._internalSetup(wrapper, globalObject);
|
||||
Object.defineProperty(wrapper, implSymbol, {
|
||||
value: Object.create(Impl.implementation.prototype),
|
||||
configurable: true
|
||||
});
|
||||
|
||||
wrapper[implSymbol][utils.wrapperSymbol] = wrapper;
|
||||
if (Impl.init) {
|
||||
Impl.init(wrapper[implSymbol]);
|
||||
}
|
||||
const args = [];
|
||||
{
|
||||
let curArg = arguments[0];
|
||||
curArg = conversions["unsigned long"](curArg, {
|
||||
context: "Failed to execute 'replaceData' on 'CharacterData': parameter 1"
|
||||
});
|
||||
args.push(curArg);
|
||||
}
|
||||
{
|
||||
let curArg = arguments[1];
|
||||
curArg = conversions["unsigned long"](curArg, {
|
||||
context: "Failed to execute 'replaceData' on 'CharacterData': parameter 2"
|
||||
});
|
||||
args.push(curArg);
|
||||
}
|
||||
{
|
||||
let curArg = arguments[2];
|
||||
curArg = conversions["DOMString"](curArg, {
|
||||
context: "Failed to execute 'replaceData' on 'CharacterData': parameter 3"
|
||||
});
|
||||
args.push(curArg);
|
||||
}
|
||||
return this[impl].replaceData(...args);
|
||||
return wrapper[implSymbol];
|
||||
};
|
||||
|
||||
CharacterData.prototype.before = function before() {
|
||||
if (!this || !module.exports.is(this)) {
|
||||
throw new TypeError("Illegal invocation");
|
||||
}
|
||||
const args = [];
|
||||
for (let i = 0; i < arguments.length; i++) {
|
||||
let curArg = arguments[i];
|
||||
if (isNode(curArg)) {
|
||||
curArg = utils.implForWrapper(curArg);
|
||||
} else {
|
||||
curArg = conversions["DOMString"](curArg, {
|
||||
context: "Failed to execute 'before' on 'CharacterData': parameter " + (i + 1)
|
||||
});
|
||||
}
|
||||
args.push(curArg);
|
||||
}
|
||||
return this[impl].before(...args);
|
||||
};
|
||||
const exposed = new Set(["Window"]);
|
||||
|
||||
CharacterData.prototype.after = function after() {
|
||||
if (!this || !module.exports.is(this)) {
|
||||
throw new TypeError("Illegal invocation");
|
||||
}
|
||||
const args = [];
|
||||
for (let i = 0; i < arguments.length; i++) {
|
||||
let curArg = arguments[i];
|
||||
if (isNode(curArg)) {
|
||||
curArg = utils.implForWrapper(curArg);
|
||||
} else {
|
||||
curArg = conversions["DOMString"](curArg, {
|
||||
context: "Failed to execute 'after' on 'CharacterData': parameter " + (i + 1)
|
||||
});
|
||||
}
|
||||
args.push(curArg);
|
||||
}
|
||||
return this[impl].after(...args);
|
||||
};
|
||||
|
||||
CharacterData.prototype.replaceWith = function replaceWith() {
|
||||
if (!this || !module.exports.is(this)) {
|
||||
throw new TypeError("Illegal invocation");
|
||||
}
|
||||
const args = [];
|
||||
for (let i = 0; i < arguments.length; i++) {
|
||||
let curArg = arguments[i];
|
||||
if (isNode(curArg)) {
|
||||
curArg = utils.implForWrapper(curArg);
|
||||
} else {
|
||||
curArg = conversions["DOMString"](curArg, {
|
||||
context: "Failed to execute 'replaceWith' on 'CharacterData': parameter " + (i + 1)
|
||||
});
|
||||
}
|
||||
args.push(curArg);
|
||||
}
|
||||
return this[impl].replaceWith(...args);
|
||||
};
|
||||
|
||||
CharacterData.prototype.remove = function remove() {
|
||||
if (!this || !module.exports.is(this)) {
|
||||
throw new TypeError("Illegal invocation");
|
||||
exports.install = (globalObject, globalNames) => {
|
||||
if (!globalNames.some(globalName => exposed.has(globalName))) {
|
||||
return;
|
||||
}
|
||||
|
||||
return this[impl].remove();
|
||||
};
|
||||
|
||||
Object.defineProperty(CharacterData.prototype, "data", {
|
||||
get() {
|
||||
if (!this || !module.exports.is(this)) {
|
||||
throw new TypeError("Illegal invocation");
|
||||
if (globalObject.Node === undefined) {
|
||||
throw new Error("Internal error: attempting to evaluate CharacterData before Node");
|
||||
}
|
||||
class CharacterData extends globalObject.Node {
|
||||
constructor() {
|
||||
throw new TypeError("Illegal constructor");
|
||||
}
|
||||
|
||||
return this[impl]["data"];
|
||||
},
|
||||
|
||||
set(V) {
|
||||
if (!this || !module.exports.is(this)) {
|
||||
throw new TypeError("Illegal invocation");
|
||||
}
|
||||
|
||||
V = conversions["DOMString"](V, {
|
||||
context: "Failed to set the 'data' property on 'CharacterData': The provided value",
|
||||
treatNullAsEmptyString: true
|
||||
});
|
||||
|
||||
this[impl]["data"] = V;
|
||||
},
|
||||
|
||||
enumerable: true,
|
||||
configurable: true
|
||||
});
|
||||
|
||||
Object.defineProperty(CharacterData.prototype, "length", {
|
||||
get() {
|
||||
if (!this || !module.exports.is(this)) {
|
||||
throw new TypeError("Illegal invocation");
|
||||
}
|
||||
|
||||
return this[impl]["length"];
|
||||
},
|
||||
|
||||
enumerable: true,
|
||||
configurable: true
|
||||
});
|
||||
|
||||
Object.defineProperty(CharacterData.prototype, "previousElementSibling", {
|
||||
get() {
|
||||
if (!this || !module.exports.is(this)) {
|
||||
throw new TypeError("Illegal invocation");
|
||||
}
|
||||
|
||||
return utils.tryWrapperForImpl(this[impl]["previousElementSibling"]);
|
||||
},
|
||||
|
||||
enumerable: true,
|
||||
configurable: true
|
||||
});
|
||||
|
||||
Object.defineProperty(CharacterData.prototype, "nextElementSibling", {
|
||||
get() {
|
||||
if (!this || !module.exports.is(this)) {
|
||||
throw new TypeError("Illegal invocation");
|
||||
}
|
||||
|
||||
return utils.tryWrapperForImpl(this[impl]["nextElementSibling"]);
|
||||
},
|
||||
|
||||
enumerable: true,
|
||||
configurable: true
|
||||
});
|
||||
|
||||
Object.defineProperty(CharacterData.prototype, Symbol.toStringTag, {
|
||||
value: "CharacterData",
|
||||
writable: false,
|
||||
enumerable: false,
|
||||
configurable: true
|
||||
});
|
||||
|
||||
const iface = {
|
||||
// When an interface-module that implements this interface as a mixin is loaded, it will append its own `.is()`
|
||||
// method into this array. It allows objects that directly implements *those* interfaces to be recognized as
|
||||
// implementing this mixin interface.
|
||||
_mixedIntoPredicates: [],
|
||||
is(obj) {
|
||||
if (obj) {
|
||||
if (utils.hasOwn(obj, impl) && obj[impl] instanceof Impl.implementation) {
|
||||
return true;
|
||||
substringData(offset, count) {
|
||||
const esValue = this !== null && this !== undefined ? this : globalObject;
|
||||
if (!exports.is(esValue)) {
|
||||
throw new TypeError("Illegal invocation");
|
||||
}
|
||||
for (const isMixedInto of module.exports._mixedIntoPredicates) {
|
||||
if (isMixedInto(obj)) {
|
||||
return true;
|
||||
|
||||
if (arguments.length < 2) {
|
||||
throw new TypeError(
|
||||
"Failed to execute 'substringData' on 'CharacterData': 2 arguments required, but only " +
|
||||
arguments.length +
|
||||
" present."
|
||||
);
|
||||
}
|
||||
const args = [];
|
||||
{
|
||||
let curArg = arguments[0];
|
||||
curArg = conversions["unsigned long"](curArg, {
|
||||
context: "Failed to execute 'substringData' on 'CharacterData': parameter 1"
|
||||
});
|
||||
args.push(curArg);
|
||||
}
|
||||
{
|
||||
let curArg = arguments[1];
|
||||
curArg = conversions["unsigned long"](curArg, {
|
||||
context: "Failed to execute 'substringData' on 'CharacterData': parameter 2"
|
||||
});
|
||||
args.push(curArg);
|
||||
}
|
||||
return esValue[implSymbol].substringData(...args);
|
||||
}
|
||||
|
||||
appendData(data) {
|
||||
const esValue = this !== null && this !== undefined ? this : globalObject;
|
||||
if (!exports.is(esValue)) {
|
||||
throw new TypeError("Illegal invocation");
|
||||
}
|
||||
|
||||
if (arguments.length < 1) {
|
||||
throw new TypeError(
|
||||
"Failed to execute 'appendData' on 'CharacterData': 1 argument required, but only " +
|
||||
arguments.length +
|
||||
" present."
|
||||
);
|
||||
}
|
||||
const args = [];
|
||||
{
|
||||
let curArg = arguments[0];
|
||||
curArg = conversions["DOMString"](curArg, {
|
||||
context: "Failed to execute 'appendData' on 'CharacterData': parameter 1"
|
||||
});
|
||||
args.push(curArg);
|
||||
}
|
||||
return esValue[implSymbol].appendData(...args);
|
||||
}
|
||||
|
||||
insertData(offset, data) {
|
||||
const esValue = this !== null && this !== undefined ? this : globalObject;
|
||||
if (!exports.is(esValue)) {
|
||||
throw new TypeError("Illegal invocation");
|
||||
}
|
||||
|
||||
if (arguments.length < 2) {
|
||||
throw new TypeError(
|
||||
"Failed to execute 'insertData' on 'CharacterData': 2 arguments required, but only " +
|
||||
arguments.length +
|
||||
" present."
|
||||
);
|
||||
}
|
||||
const args = [];
|
||||
{
|
||||
let curArg = arguments[0];
|
||||
curArg = conversions["unsigned long"](curArg, {
|
||||
context: "Failed to execute 'insertData' on 'CharacterData': parameter 1"
|
||||
});
|
||||
args.push(curArg);
|
||||
}
|
||||
{
|
||||
let curArg = arguments[1];
|
||||
curArg = conversions["DOMString"](curArg, {
|
||||
context: "Failed to execute 'insertData' on 'CharacterData': parameter 2"
|
||||
});
|
||||
args.push(curArg);
|
||||
}
|
||||
return esValue[implSymbol].insertData(...args);
|
||||
}
|
||||
|
||||
deleteData(offset, count) {
|
||||
const esValue = this !== null && this !== undefined ? this : globalObject;
|
||||
if (!exports.is(esValue)) {
|
||||
throw new TypeError("Illegal invocation");
|
||||
}
|
||||
|
||||
if (arguments.length < 2) {
|
||||
throw new TypeError(
|
||||
"Failed to execute 'deleteData' on 'CharacterData': 2 arguments required, but only " +
|
||||
arguments.length +
|
||||
" present."
|
||||
);
|
||||
}
|
||||
const args = [];
|
||||
{
|
||||
let curArg = arguments[0];
|
||||
curArg = conversions["unsigned long"](curArg, {
|
||||
context: "Failed to execute 'deleteData' on 'CharacterData': parameter 1"
|
||||
});
|
||||
args.push(curArg);
|
||||
}
|
||||
{
|
||||
let curArg = arguments[1];
|
||||
curArg = conversions["unsigned long"](curArg, {
|
||||
context: "Failed to execute 'deleteData' on 'CharacterData': parameter 2"
|
||||
});
|
||||
args.push(curArg);
|
||||
}
|
||||
return esValue[implSymbol].deleteData(...args);
|
||||
}
|
||||
|
||||
replaceData(offset, count, data) {
|
||||
const esValue = this !== null && this !== undefined ? this : globalObject;
|
||||
if (!exports.is(esValue)) {
|
||||
throw new TypeError("Illegal invocation");
|
||||
}
|
||||
|
||||
if (arguments.length < 3) {
|
||||
throw new TypeError(
|
||||
"Failed to execute 'replaceData' on 'CharacterData': 3 arguments required, but only " +
|
||||
arguments.length +
|
||||
" present."
|
||||
);
|
||||
}
|
||||
const args = [];
|
||||
{
|
||||
let curArg = arguments[0];
|
||||
curArg = conversions["unsigned long"](curArg, {
|
||||
context: "Failed to execute 'replaceData' on 'CharacterData': parameter 1"
|
||||
});
|
||||
args.push(curArg);
|
||||
}
|
||||
{
|
||||
let curArg = arguments[1];
|
||||
curArg = conversions["unsigned long"](curArg, {
|
||||
context: "Failed to execute 'replaceData' on 'CharacterData': parameter 2"
|
||||
});
|
||||
args.push(curArg);
|
||||
}
|
||||
{
|
||||
let curArg = arguments[2];
|
||||
curArg = conversions["DOMString"](curArg, {
|
||||
context: "Failed to execute 'replaceData' on 'CharacterData': parameter 3"
|
||||
});
|
||||
args.push(curArg);
|
||||
}
|
||||
return esValue[implSymbol].replaceData(...args);
|
||||
}
|
||||
|
||||
before() {
|
||||
const esValue = this !== null && this !== undefined ? this : globalObject;
|
||||
if (!exports.is(esValue)) {
|
||||
throw new TypeError("Illegal invocation");
|
||||
}
|
||||
const args = [];
|
||||
for (let i = 0; i < arguments.length; i++) {
|
||||
let curArg = arguments[i];
|
||||
if (Node.is(curArg)) {
|
||||
curArg = utils.implForWrapper(curArg);
|
||||
} else {
|
||||
curArg = conversions["DOMString"](curArg, {
|
||||
context: "Failed to execute 'before' on 'CharacterData': parameter " + (i + 1)
|
||||
});
|
||||
}
|
||||
args.push(curArg);
|
||||
}
|
||||
ceReactionsPreSteps_helpers_custom_elements(globalObject);
|
||||
try {
|
||||
return esValue[implSymbol].before(...args);
|
||||
} finally {
|
||||
ceReactionsPostSteps_helpers_custom_elements(globalObject);
|
||||
}
|
||||
}
|
||||
return false;
|
||||
},
|
||||
isImpl(obj) {
|
||||
if (obj) {
|
||||
if (obj instanceof Impl.implementation) {
|
||||
return true;
|
||||
}
|
||||
|
||||
const wrapper = utils.wrapperForImpl(obj);
|
||||
for (const isMixedInto of module.exports._mixedIntoPredicates) {
|
||||
if (isMixedInto(wrapper)) {
|
||||
return true;
|
||||
after() {
|
||||
const esValue = this !== null && this !== undefined ? this : globalObject;
|
||||
if (!exports.is(esValue)) {
|
||||
throw new TypeError("Illegal invocation");
|
||||
}
|
||||
const args = [];
|
||||
for (let i = 0; i < arguments.length; i++) {
|
||||
let curArg = arguments[i];
|
||||
if (Node.is(curArg)) {
|
||||
curArg = utils.implForWrapper(curArg);
|
||||
} else {
|
||||
curArg = conversions["DOMString"](curArg, {
|
||||
context: "Failed to execute 'after' on 'CharacterData': parameter " + (i + 1)
|
||||
});
|
||||
}
|
||||
args.push(curArg);
|
||||
}
|
||||
ceReactionsPreSteps_helpers_custom_elements(globalObject);
|
||||
try {
|
||||
return esValue[implSymbol].after(...args);
|
||||
} finally {
|
||||
ceReactionsPostSteps_helpers_custom_elements(globalObject);
|
||||
}
|
||||
}
|
||||
return false;
|
||||
},
|
||||
convert(obj, { context = "The provided value" } = {}) {
|
||||
if (module.exports.is(obj)) {
|
||||
return utils.implForWrapper(obj);
|
||||
|
||||
replaceWith() {
|
||||
const esValue = this !== null && this !== undefined ? this : globalObject;
|
||||
if (!exports.is(esValue)) {
|
||||
throw new TypeError("Illegal invocation");
|
||||
}
|
||||
const args = [];
|
||||
for (let i = 0; i < arguments.length; i++) {
|
||||
let curArg = arguments[i];
|
||||
if (Node.is(curArg)) {
|
||||
curArg = utils.implForWrapper(curArg);
|
||||
} else {
|
||||
curArg = conversions["DOMString"](curArg, {
|
||||
context: "Failed to execute 'replaceWith' on 'CharacterData': parameter " + (i + 1)
|
||||
});
|
||||
}
|
||||
args.push(curArg);
|
||||
}
|
||||
ceReactionsPreSteps_helpers_custom_elements(globalObject);
|
||||
try {
|
||||
return esValue[implSymbol].replaceWith(...args);
|
||||
} finally {
|
||||
ceReactionsPostSteps_helpers_custom_elements(globalObject);
|
||||
}
|
||||
}
|
||||
throw new TypeError(`${context} is not of type 'CharacterData'.`);
|
||||
},
|
||||
|
||||
create(constructorArgs, privateData) {
|
||||
let obj = Object.create(CharacterData.prototype);
|
||||
obj = this.setup(obj, constructorArgs, privateData);
|
||||
return obj;
|
||||
},
|
||||
createImpl(constructorArgs, privateData) {
|
||||
let obj = Object.create(CharacterData.prototype);
|
||||
obj = this.setup(obj, constructorArgs, privateData);
|
||||
return utils.implForWrapper(obj);
|
||||
},
|
||||
_internalSetup(obj) {
|
||||
Node._internalSetup(obj);
|
||||
},
|
||||
setup(obj, constructorArgs, privateData) {
|
||||
if (!privateData) privateData = {};
|
||||
remove() {
|
||||
const esValue = this !== null && this !== undefined ? this : globalObject;
|
||||
if (!exports.is(esValue)) {
|
||||
throw new TypeError("Illegal invocation");
|
||||
}
|
||||
|
||||
privateData.wrapper = obj;
|
||||
ceReactionsPreSteps_helpers_custom_elements(globalObject);
|
||||
try {
|
||||
return esValue[implSymbol].remove();
|
||||
} finally {
|
||||
ceReactionsPostSteps_helpers_custom_elements(globalObject);
|
||||
}
|
||||
}
|
||||
|
||||
this._internalSetup(obj);
|
||||
Object.defineProperty(obj, impl, {
|
||||
value: new Impl.implementation(constructorArgs, privateData),
|
||||
writable: false,
|
||||
enumerable: false,
|
||||
get data() {
|
||||
const esValue = this !== null && this !== undefined ? this : globalObject;
|
||||
|
||||
if (!exports.is(esValue)) {
|
||||
throw new TypeError("Illegal invocation");
|
||||
}
|
||||
|
||||
return esValue[implSymbol]["data"];
|
||||
}
|
||||
|
||||
set data(V) {
|
||||
const esValue = this !== null && this !== undefined ? this : globalObject;
|
||||
|
||||
if (!exports.is(esValue)) {
|
||||
throw new TypeError("Illegal invocation");
|
||||
}
|
||||
|
||||
V = conversions["DOMString"](V, {
|
||||
context: "Failed to set the 'data' property on 'CharacterData': The provided value",
|
||||
treatNullAsEmptyString: true
|
||||
});
|
||||
|
||||
esValue[implSymbol]["data"] = V;
|
||||
}
|
||||
|
||||
get length() {
|
||||
const esValue = this !== null && this !== undefined ? this : globalObject;
|
||||
|
||||
if (!exports.is(esValue)) {
|
||||
throw new TypeError("Illegal invocation");
|
||||
}
|
||||
|
||||
return esValue[implSymbol]["length"];
|
||||
}
|
||||
|
||||
get previousElementSibling() {
|
||||
const esValue = this !== null && this !== undefined ? this : globalObject;
|
||||
|
||||
if (!exports.is(esValue)) {
|
||||
throw new TypeError("Illegal invocation");
|
||||
}
|
||||
|
||||
return utils.tryWrapperForImpl(esValue[implSymbol]["previousElementSibling"]);
|
||||
}
|
||||
|
||||
get nextElementSibling() {
|
||||
const esValue = this !== null && this !== undefined ? this : globalObject;
|
||||
|
||||
if (!exports.is(esValue)) {
|
||||
throw new TypeError("Illegal invocation");
|
||||
}
|
||||
|
||||
return utils.tryWrapperForImpl(esValue[implSymbol]["nextElementSibling"]);
|
||||
}
|
||||
}
|
||||
Object.defineProperties(CharacterData.prototype, {
|
||||
substringData: { enumerable: true },
|
||||
appendData: { enumerable: true },
|
||||
insertData: { enumerable: true },
|
||||
deleteData: { enumerable: true },
|
||||
replaceData: { enumerable: true },
|
||||
before: { enumerable: true },
|
||||
after: { enumerable: true },
|
||||
replaceWith: { enumerable: true },
|
||||
remove: { enumerable: true },
|
||||
data: { enumerable: true },
|
||||
length: { enumerable: true },
|
||||
previousElementSibling: { enumerable: true },
|
||||
nextElementSibling: { enumerable: true },
|
||||
[Symbol.toStringTag]: { value: "CharacterData", configurable: true },
|
||||
[Symbol.unscopables]: {
|
||||
value: { before: true, after: true, replaceWith: true, remove: true, __proto__: null },
|
||||
configurable: true
|
||||
});
|
||||
|
||||
obj[impl][utils.wrapperSymbol] = obj;
|
||||
if (Impl.init) {
|
||||
Impl.init(obj[impl], privateData);
|
||||
}
|
||||
return obj;
|
||||
},
|
||||
interface: CharacterData,
|
||||
expose: {
|
||||
Window: { CharacterData }
|
||||
});
|
||||
if (globalObject[ctorRegistrySymbol] === undefined) {
|
||||
globalObject[ctorRegistrySymbol] = Object.create(null);
|
||||
}
|
||||
}; // iface
|
||||
module.exports = iface;
|
||||
globalObject[ctorRegistrySymbol][interfaceName] = CharacterData;
|
||||
|
||||
ChildNode._mixedIntoPredicates.push(module.exports.is);
|
||||
|
||||
NonDocumentTypeChildNode._mixedIntoPredicates.push(module.exports.is);
|
||||
Object.defineProperty(globalObject, interfaceName, {
|
||||
configurable: true,
|
||||
writable: true,
|
||||
value: CharacterData
|
||||
});
|
||||
};
|
||||
|
||||
const Impl = require("../nodes/CharacterData-impl.js");
|
||||
|
||||
179
node_modules/jsdom/lib/jsdom/living/generated/ChildNode.js
generated
vendored
179
node_modules/jsdom/lib/jsdom/living/generated/ChildNode.js
generated
vendored
@@ -1,179 +0,0 @@
|
||||
"use strict";
|
||||
|
||||
const conversions = require("webidl-conversions");
|
||||
const utils = require("./utils.js");
|
||||
|
||||
const isNode = require("./Node.js").is;
|
||||
const impl = utils.implSymbol;
|
||||
|
||||
function ChildNode() {
|
||||
throw new TypeError("Illegal constructor");
|
||||
}
|
||||
|
||||
Object.defineProperty(ChildNode, "prototype", {
|
||||
value: ChildNode.prototype,
|
||||
writable: false,
|
||||
enumerable: false,
|
||||
configurable: false
|
||||
});
|
||||
|
||||
ChildNode.prototype.before = function before() {
|
||||
if (!this || !module.exports.is(this)) {
|
||||
throw new TypeError("Illegal invocation");
|
||||
}
|
||||
const args = [];
|
||||
for (let i = 0; i < arguments.length; i++) {
|
||||
let curArg = arguments[i];
|
||||
if (isNode(curArg)) {
|
||||
curArg = utils.implForWrapper(curArg);
|
||||
} else {
|
||||
curArg = conversions["DOMString"](curArg, {
|
||||
context: "Failed to execute 'before' on 'ChildNode': parameter " + (i + 1)
|
||||
});
|
||||
}
|
||||
args.push(curArg);
|
||||
}
|
||||
return this[impl].before(...args);
|
||||
};
|
||||
|
||||
ChildNode.prototype.after = function after() {
|
||||
if (!this || !module.exports.is(this)) {
|
||||
throw new TypeError("Illegal invocation");
|
||||
}
|
||||
const args = [];
|
||||
for (let i = 0; i < arguments.length; i++) {
|
||||
let curArg = arguments[i];
|
||||
if (isNode(curArg)) {
|
||||
curArg = utils.implForWrapper(curArg);
|
||||
} else {
|
||||
curArg = conversions["DOMString"](curArg, {
|
||||
context: "Failed to execute 'after' on 'ChildNode': parameter " + (i + 1)
|
||||
});
|
||||
}
|
||||
args.push(curArg);
|
||||
}
|
||||
return this[impl].after(...args);
|
||||
};
|
||||
|
||||
ChildNode.prototype.replaceWith = function replaceWith() {
|
||||
if (!this || !module.exports.is(this)) {
|
||||
throw new TypeError("Illegal invocation");
|
||||
}
|
||||
const args = [];
|
||||
for (let i = 0; i < arguments.length; i++) {
|
||||
let curArg = arguments[i];
|
||||
if (isNode(curArg)) {
|
||||
curArg = utils.implForWrapper(curArg);
|
||||
} else {
|
||||
curArg = conversions["DOMString"](curArg, {
|
||||
context: "Failed to execute 'replaceWith' on 'ChildNode': parameter " + (i + 1)
|
||||
});
|
||||
}
|
||||
args.push(curArg);
|
||||
}
|
||||
return this[impl].replaceWith(...args);
|
||||
};
|
||||
|
||||
ChildNode.prototype.remove = function remove() {
|
||||
if (!this || !module.exports.is(this)) {
|
||||
throw new TypeError("Illegal invocation");
|
||||
}
|
||||
|
||||
return this[impl].remove();
|
||||
};
|
||||
|
||||
Object.defineProperty(ChildNode.prototype, Symbol.unscopables, {
|
||||
value: {
|
||||
before: true,
|
||||
after: true,
|
||||
replaceWith: true,
|
||||
remove: true
|
||||
},
|
||||
writable: false,
|
||||
enumerable: false,
|
||||
configurable: true
|
||||
});
|
||||
|
||||
Object.defineProperty(ChildNode.prototype, Symbol.toStringTag, {
|
||||
value: "ChildNode",
|
||||
writable: false,
|
||||
enumerable: false,
|
||||
configurable: true
|
||||
});
|
||||
|
||||
const iface = {
|
||||
// When an interface-module that implements this interface as a mixin is loaded, it will append its own `.is()`
|
||||
// method into this array. It allows objects that directly implements *those* interfaces to be recognized as
|
||||
// implementing this mixin interface.
|
||||
_mixedIntoPredicates: [],
|
||||
is(obj) {
|
||||
if (obj) {
|
||||
if (utils.hasOwn(obj, impl) && obj[impl] instanceof Impl.implementation) {
|
||||
return true;
|
||||
}
|
||||
for (const isMixedInto of module.exports._mixedIntoPredicates) {
|
||||
if (isMixedInto(obj)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
},
|
||||
isImpl(obj) {
|
||||
if (obj) {
|
||||
if (obj instanceof Impl.implementation) {
|
||||
return true;
|
||||
}
|
||||
|
||||
const wrapper = utils.wrapperForImpl(obj);
|
||||
for (const isMixedInto of module.exports._mixedIntoPredicates) {
|
||||
if (isMixedInto(wrapper)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
},
|
||||
convert(obj, { context = "The provided value" } = {}) {
|
||||
if (module.exports.is(obj)) {
|
||||
return utils.implForWrapper(obj);
|
||||
}
|
||||
throw new TypeError(`${context} is not of type 'ChildNode'.`);
|
||||
},
|
||||
|
||||
create(constructorArgs, privateData) {
|
||||
let obj = Object.create(ChildNode.prototype);
|
||||
obj = this.setup(obj, constructorArgs, privateData);
|
||||
return obj;
|
||||
},
|
||||
createImpl(constructorArgs, privateData) {
|
||||
let obj = Object.create(ChildNode.prototype);
|
||||
obj = this.setup(obj, constructorArgs, privateData);
|
||||
return utils.implForWrapper(obj);
|
||||
},
|
||||
_internalSetup(obj) {},
|
||||
setup(obj, constructorArgs, privateData) {
|
||||
if (!privateData) privateData = {};
|
||||
|
||||
privateData.wrapper = obj;
|
||||
|
||||
this._internalSetup(obj);
|
||||
Object.defineProperty(obj, impl, {
|
||||
value: new Impl.implementation(constructorArgs, privateData),
|
||||
writable: false,
|
||||
enumerable: false,
|
||||
configurable: true
|
||||
});
|
||||
|
||||
obj[impl][utils.wrapperSymbol] = obj;
|
||||
if (Impl.init) {
|
||||
Impl.init(obj[impl], privateData);
|
||||
}
|
||||
return obj;
|
||||
},
|
||||
interface: ChildNode,
|
||||
expose: {}
|
||||
}; // iface
|
||||
module.exports = iface;
|
||||
|
||||
const Impl = require("../nodes/ChildNode-impl.js");
|
||||
296
node_modules/jsdom/lib/jsdom/living/generated/CloseEvent.js
generated
vendored
296
node_modules/jsdom/lib/jsdom/living/generated/CloseEvent.js
generated
vendored
@@ -3,172 +3,162 @@
|
||||
const conversions = require("webidl-conversions");
|
||||
const utils = require("./utils.js");
|
||||
|
||||
const convertCloseEventInit = require("./CloseEventInit.js").convert;
|
||||
const impl = utils.implSymbol;
|
||||
const CloseEventInit = require("./CloseEventInit.js");
|
||||
const implSymbol = utils.implSymbol;
|
||||
const ctorRegistrySymbol = utils.ctorRegistrySymbol;
|
||||
const Event = require("./Event.js");
|
||||
|
||||
function CloseEvent(type) {
|
||||
if (new.target === undefined) {
|
||||
throw new TypeError(
|
||||
"Failed to construct 'CloseEvent'. Please use the 'new' operator; this constructor " +
|
||||
"cannot be called as a function."
|
||||
);
|
||||
const interfaceName = "CloseEvent";
|
||||
|
||||
exports.is = value => {
|
||||
return utils.isObject(value) && utils.hasOwn(value, implSymbol) && value[implSymbol] instanceof Impl.implementation;
|
||||
};
|
||||
exports.isImpl = value => {
|
||||
return utils.isObject(value) && value instanceof Impl.implementation;
|
||||
};
|
||||
exports.convert = (value, { context = "The provided value" } = {}) => {
|
||||
if (exports.is(value)) {
|
||||
return utils.implForWrapper(value);
|
||||
}
|
||||
throw new TypeError(`${context} is not of type 'CloseEvent'.`);
|
||||
};
|
||||
|
||||
function makeWrapper(globalObject) {
|
||||
if (globalObject[ctorRegistrySymbol] === undefined) {
|
||||
throw new Error("Internal error: invalid global object");
|
||||
}
|
||||
|
||||
if (arguments.length < 1) {
|
||||
throw new TypeError(
|
||||
"Failed to construct 'CloseEvent': 1 argument required, but only " + arguments.length + " present."
|
||||
);
|
||||
}
|
||||
const args = [];
|
||||
{
|
||||
let curArg = arguments[0];
|
||||
curArg = conversions["DOMString"](curArg, { context: "Failed to construct 'CloseEvent': parameter 1" });
|
||||
args.push(curArg);
|
||||
}
|
||||
{
|
||||
let curArg = arguments[1];
|
||||
curArg = convertCloseEventInit(curArg, { context: "Failed to construct 'CloseEvent': parameter 2" });
|
||||
args.push(curArg);
|
||||
const ctor = globalObject[ctorRegistrySymbol]["CloseEvent"];
|
||||
if (ctor === undefined) {
|
||||
throw new Error("Internal error: constructor CloseEvent is not installed on the passed global object");
|
||||
}
|
||||
|
||||
iface.setup(this, args);
|
||||
return Object.create(ctor.prototype);
|
||||
}
|
||||
|
||||
Object.setPrototypeOf(CloseEvent.prototype, Event.interface.prototype);
|
||||
Object.setPrototypeOf(CloseEvent, Event.interface);
|
||||
exports.create = (globalObject, constructorArgs, privateData) => {
|
||||
const wrapper = makeWrapper(globalObject);
|
||||
return exports.setup(wrapper, globalObject, constructorArgs, privateData);
|
||||
};
|
||||
|
||||
Object.defineProperty(CloseEvent, "prototype", {
|
||||
value: CloseEvent.prototype,
|
||||
writable: false,
|
||||
enumerable: false,
|
||||
configurable: false
|
||||
});
|
||||
exports.createImpl = (globalObject, constructorArgs, privateData) => {
|
||||
const wrapper = exports.create(globalObject, constructorArgs, privateData);
|
||||
return utils.implForWrapper(wrapper);
|
||||
};
|
||||
|
||||
Object.defineProperty(CloseEvent.prototype, "wasClean", {
|
||||
get() {
|
||||
if (!this || !module.exports.is(this)) {
|
||||
throw new TypeError("Illegal invocation");
|
||||
}
|
||||
exports._internalSetup = (wrapper, globalObject) => {
|
||||
Event._internalSetup(wrapper, globalObject);
|
||||
};
|
||||
|
||||
return this[impl]["wasClean"];
|
||||
},
|
||||
exports.setup = (wrapper, globalObject, constructorArgs = [], privateData = {}) => {
|
||||
privateData.wrapper = wrapper;
|
||||
|
||||
enumerable: true,
|
||||
configurable: true
|
||||
});
|
||||
exports._internalSetup(wrapper, globalObject);
|
||||
Object.defineProperty(wrapper, implSymbol, {
|
||||
value: new Impl.implementation(globalObject, constructorArgs, privateData),
|
||||
configurable: true
|
||||
});
|
||||
|
||||
Object.defineProperty(CloseEvent.prototype, "code", {
|
||||
get() {
|
||||
if (!this || !module.exports.is(this)) {
|
||||
throw new TypeError("Illegal invocation");
|
||||
}
|
||||
|
||||
return this[impl]["code"];
|
||||
},
|
||||
|
||||
enumerable: true,
|
||||
configurable: true
|
||||
});
|
||||
|
||||
Object.defineProperty(CloseEvent.prototype, "reason", {
|
||||
get() {
|
||||
if (!this || !module.exports.is(this)) {
|
||||
throw new TypeError("Illegal invocation");
|
||||
}
|
||||
|
||||
return this[impl]["reason"];
|
||||
},
|
||||
|
||||
enumerable: true,
|
||||
configurable: true
|
||||
});
|
||||
|
||||
Object.defineProperty(CloseEvent.prototype, Symbol.toStringTag, {
|
||||
value: "CloseEvent",
|
||||
writable: false,
|
||||
enumerable: false,
|
||||
configurable: true
|
||||
});
|
||||
|
||||
const iface = {
|
||||
// When an interface-module that implements this interface as a mixin is loaded, it will append its own `.is()`
|
||||
// method into this array. It allows objects that directly implements *those* interfaces to be recognized as
|
||||
// implementing this mixin interface.
|
||||
_mixedIntoPredicates: [],
|
||||
is(obj) {
|
||||
if (obj) {
|
||||
if (utils.hasOwn(obj, impl) && obj[impl] instanceof Impl.implementation) {
|
||||
return true;
|
||||
}
|
||||
for (const isMixedInto of module.exports._mixedIntoPredicates) {
|
||||
if (isMixedInto(obj)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
},
|
||||
isImpl(obj) {
|
||||
if (obj) {
|
||||
if (obj instanceof Impl.implementation) {
|
||||
return true;
|
||||
}
|
||||
|
||||
const wrapper = utils.wrapperForImpl(obj);
|
||||
for (const isMixedInto of module.exports._mixedIntoPredicates) {
|
||||
if (isMixedInto(wrapper)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
},
|
||||
convert(obj, { context = "The provided value" } = {}) {
|
||||
if (module.exports.is(obj)) {
|
||||
return utils.implForWrapper(obj);
|
||||
}
|
||||
throw new TypeError(`${context} is not of type 'CloseEvent'.`);
|
||||
},
|
||||
|
||||
create(constructorArgs, privateData) {
|
||||
let obj = Object.create(CloseEvent.prototype);
|
||||
obj = this.setup(obj, constructorArgs, privateData);
|
||||
return obj;
|
||||
},
|
||||
createImpl(constructorArgs, privateData) {
|
||||
let obj = Object.create(CloseEvent.prototype);
|
||||
obj = this.setup(obj, constructorArgs, privateData);
|
||||
return utils.implForWrapper(obj);
|
||||
},
|
||||
_internalSetup(obj) {
|
||||
Event._internalSetup(obj);
|
||||
},
|
||||
setup(obj, constructorArgs, privateData) {
|
||||
if (!privateData) privateData = {};
|
||||
|
||||
privateData.wrapper = obj;
|
||||
|
||||
this._internalSetup(obj);
|
||||
Object.defineProperty(obj, impl, {
|
||||
value: new Impl.implementation(constructorArgs, privateData),
|
||||
writable: false,
|
||||
enumerable: false,
|
||||
configurable: true
|
||||
});
|
||||
|
||||
obj[impl][utils.wrapperSymbol] = obj;
|
||||
if (Impl.init) {
|
||||
Impl.init(obj[impl], privateData);
|
||||
}
|
||||
return obj;
|
||||
},
|
||||
interface: CloseEvent,
|
||||
expose: {
|
||||
Window: { CloseEvent },
|
||||
Worker: { CloseEvent }
|
||||
wrapper[implSymbol][utils.wrapperSymbol] = wrapper;
|
||||
if (Impl.init) {
|
||||
Impl.init(wrapper[implSymbol]);
|
||||
}
|
||||
}; // iface
|
||||
module.exports = iface;
|
||||
return wrapper;
|
||||
};
|
||||
|
||||
exports.new = globalObject => {
|
||||
const wrapper = makeWrapper(globalObject);
|
||||
|
||||
exports._internalSetup(wrapper, globalObject);
|
||||
Object.defineProperty(wrapper, implSymbol, {
|
||||
value: Object.create(Impl.implementation.prototype),
|
||||
configurable: true
|
||||
});
|
||||
|
||||
wrapper[implSymbol][utils.wrapperSymbol] = wrapper;
|
||||
if (Impl.init) {
|
||||
Impl.init(wrapper[implSymbol]);
|
||||
}
|
||||
return wrapper[implSymbol];
|
||||
};
|
||||
|
||||
const exposed = new Set(["Window", "Worker"]);
|
||||
|
||||
exports.install = (globalObject, globalNames) => {
|
||||
if (!globalNames.some(globalName => exposed.has(globalName))) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (globalObject.Event === undefined) {
|
||||
throw new Error("Internal error: attempting to evaluate CloseEvent before Event");
|
||||
}
|
||||
class CloseEvent extends globalObject.Event {
|
||||
constructor(type) {
|
||||
if (arguments.length < 1) {
|
||||
throw new TypeError(
|
||||
"Failed to construct 'CloseEvent': 1 argument required, but only " + arguments.length + " present."
|
||||
);
|
||||
}
|
||||
const args = [];
|
||||
{
|
||||
let curArg = arguments[0];
|
||||
curArg = conversions["DOMString"](curArg, { context: "Failed to construct 'CloseEvent': parameter 1" });
|
||||
args.push(curArg);
|
||||
}
|
||||
{
|
||||
let curArg = arguments[1];
|
||||
curArg = CloseEventInit.convert(curArg, { context: "Failed to construct 'CloseEvent': parameter 2" });
|
||||
args.push(curArg);
|
||||
}
|
||||
return exports.setup(Object.create(new.target.prototype), globalObject, args);
|
||||
}
|
||||
|
||||
get wasClean() {
|
||||
const esValue = this !== null && this !== undefined ? this : globalObject;
|
||||
|
||||
if (!exports.is(esValue)) {
|
||||
throw new TypeError("Illegal invocation");
|
||||
}
|
||||
|
||||
return esValue[implSymbol]["wasClean"];
|
||||
}
|
||||
|
||||
get code() {
|
||||
const esValue = this !== null && this !== undefined ? this : globalObject;
|
||||
|
||||
if (!exports.is(esValue)) {
|
||||
throw new TypeError("Illegal invocation");
|
||||
}
|
||||
|
||||
return esValue[implSymbol]["code"];
|
||||
}
|
||||
|
||||
get reason() {
|
||||
const esValue = this !== null && this !== undefined ? this : globalObject;
|
||||
|
||||
if (!exports.is(esValue)) {
|
||||
throw new TypeError("Illegal invocation");
|
||||
}
|
||||
|
||||
return esValue[implSymbol]["reason"];
|
||||
}
|
||||
}
|
||||
Object.defineProperties(CloseEvent.prototype, {
|
||||
wasClean: { enumerable: true },
|
||||
code: { enumerable: true },
|
||||
reason: { enumerable: true },
|
||||
[Symbol.toStringTag]: { value: "CloseEvent", configurable: true }
|
||||
});
|
||||
if (globalObject[ctorRegistrySymbol] === undefined) {
|
||||
globalObject[ctorRegistrySymbol] = Object.create(null);
|
||||
}
|
||||
globalObject[ctorRegistrySymbol][interfaceName] = CloseEvent;
|
||||
|
||||
Object.defineProperty(globalObject, interfaceName, {
|
||||
configurable: true,
|
||||
writable: true,
|
||||
value: CloseEvent
|
||||
});
|
||||
};
|
||||
|
||||
const Impl = require("../events/CloseEvent-impl.js");
|
||||
|
||||
78
node_modules/jsdom/lib/jsdom/living/generated/CloseEventInit.js
generated
vendored
78
node_modules/jsdom/lib/jsdom/living/generated/CloseEventInit.js
generated
vendored
@@ -5,54 +5,52 @@ const utils = require("./utils.js");
|
||||
|
||||
const EventInit = require("./EventInit.js");
|
||||
|
||||
module.exports = {
|
||||
convertInherit(obj, ret, { context = "The provided value" } = {}) {
|
||||
EventInit.convertInherit(obj, ret, { context });
|
||||
exports._convertInherit = (obj, ret, { context = "The provided value" } = {}) => {
|
||||
EventInit._convertInherit(obj, ret, { context });
|
||||
|
||||
{
|
||||
const key = "code";
|
||||
let value = obj === undefined || obj === null ? undefined : obj[key];
|
||||
if (value !== undefined) {
|
||||
value = conversions["unsigned short"](value, { context: context + " has member code that" });
|
||||
{
|
||||
const key = "code";
|
||||
let value = obj === undefined || obj === null ? undefined : obj[key];
|
||||
if (value !== undefined) {
|
||||
value = conversions["unsigned short"](value, { context: context + " has member 'code' that" });
|
||||
|
||||
ret[key] = value;
|
||||
} else {
|
||||
ret[key] = 0;
|
||||
}
|
||||
ret[key] = value;
|
||||
} else {
|
||||
ret[key] = 0;
|
||||
}
|
||||
}
|
||||
|
||||
{
|
||||
const key = "reason";
|
||||
let value = obj === undefined || obj === null ? undefined : obj[key];
|
||||
if (value !== undefined) {
|
||||
value = conversions["USVString"](value, { context: context + " has member reason that" });
|
||||
{
|
||||
const key = "reason";
|
||||
let value = obj === undefined || obj === null ? undefined : obj[key];
|
||||
if (value !== undefined) {
|
||||
value = conversions["USVString"](value, { context: context + " has member 'reason' that" });
|
||||
|
||||
ret[key] = value;
|
||||
} else {
|
||||
ret[key] = "";
|
||||
}
|
||||
ret[key] = value;
|
||||
} else {
|
||||
ret[key] = "";
|
||||
}
|
||||
}
|
||||
|
||||
{
|
||||
const key = "wasClean";
|
||||
let value = obj === undefined || obj === null ? undefined : obj[key];
|
||||
if (value !== undefined) {
|
||||
value = conversions["boolean"](value, { context: context + " has member wasClean that" });
|
||||
{
|
||||
const key = "wasClean";
|
||||
let value = obj === undefined || obj === null ? undefined : obj[key];
|
||||
if (value !== undefined) {
|
||||
value = conversions["boolean"](value, { context: context + " has member 'wasClean' that" });
|
||||
|
||||
ret[key] = value;
|
||||
} else {
|
||||
ret[key] = false;
|
||||
}
|
||||
ret[key] = value;
|
||||
} else {
|
||||
ret[key] = false;
|
||||
}
|
||||
},
|
||||
|
||||
convert(obj, { context = "The provided value" } = {}) {
|
||||
if (obj !== undefined && typeof obj !== "object" && typeof obj !== "function") {
|
||||
throw new TypeError(`${context} is not an object.`);
|
||||
}
|
||||
|
||||
const ret = Object.create(null);
|
||||
module.exports.convertInherit(obj, ret, { context });
|
||||
return ret;
|
||||
}
|
||||
};
|
||||
|
||||
exports.convert = function convert(obj, { context = "The provided value" } = {}) {
|
||||
if (obj !== undefined && typeof obj !== "object" && typeof obj !== "function") {
|
||||
throw new TypeError(`${context} is not an object.`);
|
||||
}
|
||||
|
||||
const ret = Object.create(null);
|
||||
exports._convertInherit(obj, ret, { context });
|
||||
return ret;
|
||||
};
|
||||
|
||||
208
node_modules/jsdom/lib/jsdom/living/generated/Comment.js
generated
vendored
208
node_modules/jsdom/lib/jsdom/living/generated/Comment.js
generated
vendored
@@ -3,124 +3,120 @@
|
||||
const conversions = require("webidl-conversions");
|
||||
const utils = require("./utils.js");
|
||||
|
||||
const impl = utils.implSymbol;
|
||||
const implSymbol = utils.implSymbol;
|
||||
const ctorRegistrySymbol = utils.ctorRegistrySymbol;
|
||||
const CharacterData = require("./CharacterData.js");
|
||||
|
||||
function Comment() {
|
||||
if (new.target === undefined) {
|
||||
throw new TypeError(
|
||||
"Failed to construct 'Comment'. Please use the 'new' operator; this constructor " +
|
||||
"cannot be called as a function."
|
||||
);
|
||||
const interfaceName = "Comment";
|
||||
|
||||
exports.is = value => {
|
||||
return utils.isObject(value) && utils.hasOwn(value, implSymbol) && value[implSymbol] instanceof Impl.implementation;
|
||||
};
|
||||
exports.isImpl = value => {
|
||||
return utils.isObject(value) && value instanceof Impl.implementation;
|
||||
};
|
||||
exports.convert = (value, { context = "The provided value" } = {}) => {
|
||||
if (exports.is(value)) {
|
||||
return utils.implForWrapper(value);
|
||||
}
|
||||
const args = [];
|
||||
{
|
||||
let curArg = arguments[0];
|
||||
if (curArg !== undefined) {
|
||||
curArg = conversions["DOMString"](curArg, { context: "Failed to construct 'Comment': parameter 1" });
|
||||
} else {
|
||||
curArg = "";
|
||||
}
|
||||
args.push(curArg);
|
||||
throw new TypeError(`${context} is not of type 'Comment'.`);
|
||||
};
|
||||
|
||||
function makeWrapper(globalObject) {
|
||||
if (globalObject[ctorRegistrySymbol] === undefined) {
|
||||
throw new Error("Internal error: invalid global object");
|
||||
}
|
||||
|
||||
iface.setup(this, args);
|
||||
const ctor = globalObject[ctorRegistrySymbol]["Comment"];
|
||||
if (ctor === undefined) {
|
||||
throw new Error("Internal error: constructor Comment is not installed on the passed global object");
|
||||
}
|
||||
|
||||
return Object.create(ctor.prototype);
|
||||
}
|
||||
|
||||
Object.setPrototypeOf(Comment.prototype, CharacterData.interface.prototype);
|
||||
Object.setPrototypeOf(Comment, CharacterData.interface);
|
||||
exports.create = (globalObject, constructorArgs, privateData) => {
|
||||
const wrapper = makeWrapper(globalObject);
|
||||
return exports.setup(wrapper, globalObject, constructorArgs, privateData);
|
||||
};
|
||||
|
||||
Object.defineProperty(Comment, "prototype", {
|
||||
value: Comment.prototype,
|
||||
writable: false,
|
||||
enumerable: false,
|
||||
configurable: false
|
||||
});
|
||||
exports.createImpl = (globalObject, constructorArgs, privateData) => {
|
||||
const wrapper = exports.create(globalObject, constructorArgs, privateData);
|
||||
return utils.implForWrapper(wrapper);
|
||||
};
|
||||
|
||||
Object.defineProperty(Comment.prototype, Symbol.toStringTag, {
|
||||
value: "Comment",
|
||||
writable: false,
|
||||
enumerable: false,
|
||||
configurable: true
|
||||
});
|
||||
exports._internalSetup = (wrapper, globalObject) => {
|
||||
CharacterData._internalSetup(wrapper, globalObject);
|
||||
};
|
||||
|
||||
const iface = {
|
||||
// When an interface-module that implements this interface as a mixin is loaded, it will append its own `.is()`
|
||||
// method into this array. It allows objects that directly implements *those* interfaces to be recognized as
|
||||
// implementing this mixin interface.
|
||||
_mixedIntoPredicates: [],
|
||||
is(obj) {
|
||||
if (obj) {
|
||||
if (utils.hasOwn(obj, impl) && obj[impl] instanceof Impl.implementation) {
|
||||
return true;
|
||||
}
|
||||
for (const isMixedInto of module.exports._mixedIntoPredicates) {
|
||||
if (isMixedInto(obj)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
},
|
||||
isImpl(obj) {
|
||||
if (obj) {
|
||||
if (obj instanceof Impl.implementation) {
|
||||
return true;
|
||||
}
|
||||
exports.setup = (wrapper, globalObject, constructorArgs = [], privateData = {}) => {
|
||||
privateData.wrapper = wrapper;
|
||||
|
||||
const wrapper = utils.wrapperForImpl(obj);
|
||||
for (const isMixedInto of module.exports._mixedIntoPredicates) {
|
||||
if (isMixedInto(wrapper)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
},
|
||||
convert(obj, { context = "The provided value" } = {}) {
|
||||
if (module.exports.is(obj)) {
|
||||
return utils.implForWrapper(obj);
|
||||
}
|
||||
throw new TypeError(`${context} is not of type 'Comment'.`);
|
||||
},
|
||||
exports._internalSetup(wrapper, globalObject);
|
||||
Object.defineProperty(wrapper, implSymbol, {
|
||||
value: new Impl.implementation(globalObject, constructorArgs, privateData),
|
||||
configurable: true
|
||||
});
|
||||
|
||||
create(constructorArgs, privateData) {
|
||||
let obj = Object.create(Comment.prototype);
|
||||
obj = this.setup(obj, constructorArgs, privateData);
|
||||
return obj;
|
||||
},
|
||||
createImpl(constructorArgs, privateData) {
|
||||
let obj = Object.create(Comment.prototype);
|
||||
obj = this.setup(obj, constructorArgs, privateData);
|
||||
return utils.implForWrapper(obj);
|
||||
},
|
||||
_internalSetup(obj) {
|
||||
CharacterData._internalSetup(obj);
|
||||
},
|
||||
setup(obj, constructorArgs, privateData) {
|
||||
if (!privateData) privateData = {};
|
||||
|
||||
privateData.wrapper = obj;
|
||||
|
||||
this._internalSetup(obj);
|
||||
Object.defineProperty(obj, impl, {
|
||||
value: new Impl.implementation(constructorArgs, privateData),
|
||||
writable: false,
|
||||
enumerable: false,
|
||||
configurable: true
|
||||
});
|
||||
|
||||
obj[impl][utils.wrapperSymbol] = obj;
|
||||
if (Impl.init) {
|
||||
Impl.init(obj[impl], privateData);
|
||||
}
|
||||
return obj;
|
||||
},
|
||||
interface: Comment,
|
||||
expose: {
|
||||
Window: { Comment }
|
||||
wrapper[implSymbol][utils.wrapperSymbol] = wrapper;
|
||||
if (Impl.init) {
|
||||
Impl.init(wrapper[implSymbol]);
|
||||
}
|
||||
}; // iface
|
||||
module.exports = iface;
|
||||
return wrapper;
|
||||
};
|
||||
|
||||
exports.new = globalObject => {
|
||||
const wrapper = makeWrapper(globalObject);
|
||||
|
||||
exports._internalSetup(wrapper, globalObject);
|
||||
Object.defineProperty(wrapper, implSymbol, {
|
||||
value: Object.create(Impl.implementation.prototype),
|
||||
configurable: true
|
||||
});
|
||||
|
||||
wrapper[implSymbol][utils.wrapperSymbol] = wrapper;
|
||||
if (Impl.init) {
|
||||
Impl.init(wrapper[implSymbol]);
|
||||
}
|
||||
return wrapper[implSymbol];
|
||||
};
|
||||
|
||||
const exposed = new Set(["Window"]);
|
||||
|
||||
exports.install = (globalObject, globalNames) => {
|
||||
if (!globalNames.some(globalName => exposed.has(globalName))) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (globalObject.CharacterData === undefined) {
|
||||
throw new Error("Internal error: attempting to evaluate Comment before CharacterData");
|
||||
}
|
||||
class Comment extends globalObject.CharacterData {
|
||||
constructor() {
|
||||
const args = [];
|
||||
{
|
||||
let curArg = arguments[0];
|
||||
if (curArg !== undefined) {
|
||||
curArg = conversions["DOMString"](curArg, { context: "Failed to construct 'Comment': parameter 1" });
|
||||
} else {
|
||||
curArg = "";
|
||||
}
|
||||
args.push(curArg);
|
||||
}
|
||||
return exports.setup(Object.create(new.target.prototype), globalObject, args);
|
||||
}
|
||||
}
|
||||
Object.defineProperties(Comment.prototype, { [Symbol.toStringTag]: { value: "Comment", configurable: true } });
|
||||
if (globalObject[ctorRegistrySymbol] === undefined) {
|
||||
globalObject[ctorRegistrySymbol] = Object.create(null);
|
||||
}
|
||||
globalObject[ctorRegistrySymbol][interfaceName] = Comment;
|
||||
|
||||
Object.defineProperty(globalObject, interfaceName, {
|
||||
configurable: true,
|
||||
writable: true,
|
||||
value: Comment
|
||||
});
|
||||
};
|
||||
|
||||
const Impl = require("../nodes/Comment-impl.js");
|
||||
|
||||
403
node_modules/jsdom/lib/jsdom/living/generated/CompositionEvent.js
generated
vendored
403
node_modules/jsdom/lib/jsdom/living/generated/CompositionEvent.js
generated
vendored
@@ -3,214 +3,213 @@
|
||||
const conversions = require("webidl-conversions");
|
||||
const utils = require("./utils.js");
|
||||
|
||||
const convertCompositionEventInit = require("./CompositionEventInit.js").convert;
|
||||
const impl = utils.implSymbol;
|
||||
const CompositionEventInit = require("./CompositionEventInit.js");
|
||||
const implSymbol = utils.implSymbol;
|
||||
const ctorRegistrySymbol = utils.ctorRegistrySymbol;
|
||||
const UIEvent = require("./UIEvent.js");
|
||||
|
||||
function CompositionEvent(type) {
|
||||
if (new.target === undefined) {
|
||||
throw new TypeError(
|
||||
"Failed to construct 'CompositionEvent'. Please use the 'new' operator; this constructor " +
|
||||
"cannot be called as a function."
|
||||
);
|
||||
}
|
||||
const interfaceName = "CompositionEvent";
|
||||
|
||||
if (arguments.length < 1) {
|
||||
throw new TypeError(
|
||||
"Failed to construct 'CompositionEvent': 1 argument required, but only " + arguments.length + " present."
|
||||
);
|
||||
exports.is = value => {
|
||||
return utils.isObject(value) && utils.hasOwn(value, implSymbol) && value[implSymbol] instanceof Impl.implementation;
|
||||
};
|
||||
exports.isImpl = value => {
|
||||
return utils.isObject(value) && value instanceof Impl.implementation;
|
||||
};
|
||||
exports.convert = (value, { context = "The provided value" } = {}) => {
|
||||
if (exports.is(value)) {
|
||||
return utils.implForWrapper(value);
|
||||
}
|
||||
const args = [];
|
||||
{
|
||||
let curArg = arguments[0];
|
||||
curArg = conversions["DOMString"](curArg, { context: "Failed to construct 'CompositionEvent': parameter 1" });
|
||||
args.push(curArg);
|
||||
}
|
||||
{
|
||||
let curArg = arguments[1];
|
||||
curArg = convertCompositionEventInit(curArg, { context: "Failed to construct 'CompositionEvent': parameter 2" });
|
||||
args.push(curArg);
|
||||
}
|
||||
|
||||
iface.setup(this, args);
|
||||
}
|
||||
|
||||
Object.setPrototypeOf(CompositionEvent.prototype, UIEvent.interface.prototype);
|
||||
Object.setPrototypeOf(CompositionEvent, UIEvent.interface);
|
||||
|
||||
Object.defineProperty(CompositionEvent, "prototype", {
|
||||
value: CompositionEvent.prototype,
|
||||
writable: false,
|
||||
enumerable: false,
|
||||
configurable: false
|
||||
});
|
||||
|
||||
CompositionEvent.prototype.initCompositionEvent = function initCompositionEvent(typeArg) {
|
||||
if (!this || !module.exports.is(this)) {
|
||||
throw new TypeError("Illegal invocation");
|
||||
}
|
||||
|
||||
if (arguments.length < 1) {
|
||||
throw new TypeError(
|
||||
"Failed to execute 'initCompositionEvent' on 'CompositionEvent': 1 argument required, but only " +
|
||||
arguments.length +
|
||||
" present."
|
||||
);
|
||||
}
|
||||
const args = [];
|
||||
{
|
||||
let curArg = arguments[0];
|
||||
curArg = conversions["DOMString"](curArg, {
|
||||
context: "Failed to execute 'initCompositionEvent' on 'CompositionEvent': parameter 1"
|
||||
});
|
||||
args.push(curArg);
|
||||
}
|
||||
{
|
||||
let curArg = arguments[1];
|
||||
if (curArg !== undefined) {
|
||||
curArg = conversions["boolean"](curArg, {
|
||||
context: "Failed to execute 'initCompositionEvent' on 'CompositionEvent': parameter 2"
|
||||
});
|
||||
} else {
|
||||
curArg = false;
|
||||
}
|
||||
args.push(curArg);
|
||||
}
|
||||
{
|
||||
let curArg = arguments[2];
|
||||
if (curArg !== undefined) {
|
||||
curArg = conversions["boolean"](curArg, {
|
||||
context: "Failed to execute 'initCompositionEvent' on 'CompositionEvent': parameter 3"
|
||||
});
|
||||
} else {
|
||||
curArg = false;
|
||||
}
|
||||
args.push(curArg);
|
||||
}
|
||||
{
|
||||
let curArg = arguments[3];
|
||||
if (curArg !== undefined) {
|
||||
if (curArg === null || curArg === undefined) {
|
||||
curArg = null;
|
||||
} else {
|
||||
curArg = utils.tryImplForWrapper(curArg);
|
||||
}
|
||||
} else {
|
||||
curArg = null;
|
||||
}
|
||||
args.push(curArg);
|
||||
}
|
||||
{
|
||||
let curArg = arguments[4];
|
||||
if (curArg !== undefined) {
|
||||
curArg = conversions["DOMString"](curArg, {
|
||||
context: "Failed to execute 'initCompositionEvent' on 'CompositionEvent': parameter 5"
|
||||
});
|
||||
} else {
|
||||
curArg = "";
|
||||
}
|
||||
args.push(curArg);
|
||||
}
|
||||
return this[impl].initCompositionEvent(...args);
|
||||
throw new TypeError(`${context} is not of type 'CompositionEvent'.`);
|
||||
};
|
||||
|
||||
Object.defineProperty(CompositionEvent.prototype, "data", {
|
||||
get() {
|
||||
if (!this || !module.exports.is(this)) {
|
||||
throw new TypeError("Illegal invocation");
|
||||
}
|
||||
|
||||
return this[impl]["data"];
|
||||
},
|
||||
|
||||
enumerable: true,
|
||||
configurable: true
|
||||
});
|
||||
|
||||
Object.defineProperty(CompositionEvent.prototype, Symbol.toStringTag, {
|
||||
value: "CompositionEvent",
|
||||
writable: false,
|
||||
enumerable: false,
|
||||
configurable: true
|
||||
});
|
||||
|
||||
const iface = {
|
||||
// When an interface-module that implements this interface as a mixin is loaded, it will append its own `.is()`
|
||||
// method into this array. It allows objects that directly implements *those* interfaces to be recognized as
|
||||
// implementing this mixin interface.
|
||||
_mixedIntoPredicates: [],
|
||||
is(obj) {
|
||||
if (obj) {
|
||||
if (utils.hasOwn(obj, impl) && obj[impl] instanceof Impl.implementation) {
|
||||
return true;
|
||||
}
|
||||
for (const isMixedInto of module.exports._mixedIntoPredicates) {
|
||||
if (isMixedInto(obj)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
},
|
||||
isImpl(obj) {
|
||||
if (obj) {
|
||||
if (obj instanceof Impl.implementation) {
|
||||
return true;
|
||||
}
|
||||
|
||||
const wrapper = utils.wrapperForImpl(obj);
|
||||
for (const isMixedInto of module.exports._mixedIntoPredicates) {
|
||||
if (isMixedInto(wrapper)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
},
|
||||
convert(obj, { context = "The provided value" } = {}) {
|
||||
if (module.exports.is(obj)) {
|
||||
return utils.implForWrapper(obj);
|
||||
}
|
||||
throw new TypeError(`${context} is not of type 'CompositionEvent'.`);
|
||||
},
|
||||
|
||||
create(constructorArgs, privateData) {
|
||||
let obj = Object.create(CompositionEvent.prototype);
|
||||
obj = this.setup(obj, constructorArgs, privateData);
|
||||
return obj;
|
||||
},
|
||||
createImpl(constructorArgs, privateData) {
|
||||
let obj = Object.create(CompositionEvent.prototype);
|
||||
obj = this.setup(obj, constructorArgs, privateData);
|
||||
return utils.implForWrapper(obj);
|
||||
},
|
||||
_internalSetup(obj) {
|
||||
UIEvent._internalSetup(obj);
|
||||
},
|
||||
setup(obj, constructorArgs, privateData) {
|
||||
if (!privateData) privateData = {};
|
||||
|
||||
privateData.wrapper = obj;
|
||||
|
||||
this._internalSetup(obj);
|
||||
Object.defineProperty(obj, impl, {
|
||||
value: new Impl.implementation(constructorArgs, privateData),
|
||||
writable: false,
|
||||
enumerable: false,
|
||||
configurable: true
|
||||
});
|
||||
|
||||
obj[impl][utils.wrapperSymbol] = obj;
|
||||
if (Impl.init) {
|
||||
Impl.init(obj[impl], privateData);
|
||||
}
|
||||
return obj;
|
||||
},
|
||||
interface: CompositionEvent,
|
||||
expose: {
|
||||
Window: { CompositionEvent }
|
||||
function makeWrapper(globalObject) {
|
||||
if (globalObject[ctorRegistrySymbol] === undefined) {
|
||||
throw new Error("Internal error: invalid global object");
|
||||
}
|
||||
}; // iface
|
||||
module.exports = iface;
|
||||
|
||||
const ctor = globalObject[ctorRegistrySymbol]["CompositionEvent"];
|
||||
if (ctor === undefined) {
|
||||
throw new Error("Internal error: constructor CompositionEvent is not installed on the passed global object");
|
||||
}
|
||||
|
||||
return Object.create(ctor.prototype);
|
||||
}
|
||||
|
||||
exports.create = (globalObject, constructorArgs, privateData) => {
|
||||
const wrapper = makeWrapper(globalObject);
|
||||
return exports.setup(wrapper, globalObject, constructorArgs, privateData);
|
||||
};
|
||||
|
||||
exports.createImpl = (globalObject, constructorArgs, privateData) => {
|
||||
const wrapper = exports.create(globalObject, constructorArgs, privateData);
|
||||
return utils.implForWrapper(wrapper);
|
||||
};
|
||||
|
||||
exports._internalSetup = (wrapper, globalObject) => {
|
||||
UIEvent._internalSetup(wrapper, globalObject);
|
||||
};
|
||||
|
||||
exports.setup = (wrapper, globalObject, constructorArgs = [], privateData = {}) => {
|
||||
privateData.wrapper = wrapper;
|
||||
|
||||
exports._internalSetup(wrapper, globalObject);
|
||||
Object.defineProperty(wrapper, implSymbol, {
|
||||
value: new Impl.implementation(globalObject, constructorArgs, privateData),
|
||||
configurable: true
|
||||
});
|
||||
|
||||
wrapper[implSymbol][utils.wrapperSymbol] = wrapper;
|
||||
if (Impl.init) {
|
||||
Impl.init(wrapper[implSymbol]);
|
||||
}
|
||||
return wrapper;
|
||||
};
|
||||
|
||||
exports.new = globalObject => {
|
||||
const wrapper = makeWrapper(globalObject);
|
||||
|
||||
exports._internalSetup(wrapper, globalObject);
|
||||
Object.defineProperty(wrapper, implSymbol, {
|
||||
value: Object.create(Impl.implementation.prototype),
|
||||
configurable: true
|
||||
});
|
||||
|
||||
wrapper[implSymbol][utils.wrapperSymbol] = wrapper;
|
||||
if (Impl.init) {
|
||||
Impl.init(wrapper[implSymbol]);
|
||||
}
|
||||
return wrapper[implSymbol];
|
||||
};
|
||||
|
||||
const exposed = new Set(["Window"]);
|
||||
|
||||
exports.install = (globalObject, globalNames) => {
|
||||
if (!globalNames.some(globalName => exposed.has(globalName))) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (globalObject.UIEvent === undefined) {
|
||||
throw new Error("Internal error: attempting to evaluate CompositionEvent before UIEvent");
|
||||
}
|
||||
class CompositionEvent extends globalObject.UIEvent {
|
||||
constructor(type) {
|
||||
if (arguments.length < 1) {
|
||||
throw new TypeError(
|
||||
"Failed to construct 'CompositionEvent': 1 argument required, but only " + arguments.length + " present."
|
||||
);
|
||||
}
|
||||
const args = [];
|
||||
{
|
||||
let curArg = arguments[0];
|
||||
curArg = conversions["DOMString"](curArg, { context: "Failed to construct 'CompositionEvent': parameter 1" });
|
||||
args.push(curArg);
|
||||
}
|
||||
{
|
||||
let curArg = arguments[1];
|
||||
curArg = CompositionEventInit.convert(curArg, {
|
||||
context: "Failed to construct 'CompositionEvent': parameter 2"
|
||||
});
|
||||
args.push(curArg);
|
||||
}
|
||||
return exports.setup(Object.create(new.target.prototype), globalObject, args);
|
||||
}
|
||||
|
||||
initCompositionEvent(typeArg) {
|
||||
const esValue = this !== null && this !== undefined ? this : globalObject;
|
||||
if (!exports.is(esValue)) {
|
||||
throw new TypeError("Illegal invocation");
|
||||
}
|
||||
|
||||
if (arguments.length < 1) {
|
||||
throw new TypeError(
|
||||
"Failed to execute 'initCompositionEvent' on 'CompositionEvent': 1 argument required, but only " +
|
||||
arguments.length +
|
||||
" present."
|
||||
);
|
||||
}
|
||||
const args = [];
|
||||
{
|
||||
let curArg = arguments[0];
|
||||
curArg = conversions["DOMString"](curArg, {
|
||||
context: "Failed to execute 'initCompositionEvent' on 'CompositionEvent': parameter 1"
|
||||
});
|
||||
args.push(curArg);
|
||||
}
|
||||
{
|
||||
let curArg = arguments[1];
|
||||
if (curArg !== undefined) {
|
||||
curArg = conversions["boolean"](curArg, {
|
||||
context: "Failed to execute 'initCompositionEvent' on 'CompositionEvent': parameter 2"
|
||||
});
|
||||
} else {
|
||||
curArg = false;
|
||||
}
|
||||
args.push(curArg);
|
||||
}
|
||||
{
|
||||
let curArg = arguments[2];
|
||||
if (curArg !== undefined) {
|
||||
curArg = conversions["boolean"](curArg, {
|
||||
context: "Failed to execute 'initCompositionEvent' on 'CompositionEvent': parameter 3"
|
||||
});
|
||||
} else {
|
||||
curArg = false;
|
||||
}
|
||||
args.push(curArg);
|
||||
}
|
||||
{
|
||||
let curArg = arguments[3];
|
||||
if (curArg !== undefined) {
|
||||
if (curArg === null || curArg === undefined) {
|
||||
curArg = null;
|
||||
} else {
|
||||
curArg = utils.tryImplForWrapper(curArg);
|
||||
}
|
||||
} else {
|
||||
curArg = null;
|
||||
}
|
||||
args.push(curArg);
|
||||
}
|
||||
{
|
||||
let curArg = arguments[4];
|
||||
if (curArg !== undefined) {
|
||||
curArg = conversions["DOMString"](curArg, {
|
||||
context: "Failed to execute 'initCompositionEvent' on 'CompositionEvent': parameter 5"
|
||||
});
|
||||
} else {
|
||||
curArg = "";
|
||||
}
|
||||
args.push(curArg);
|
||||
}
|
||||
return esValue[implSymbol].initCompositionEvent(...args);
|
||||
}
|
||||
|
||||
get data() {
|
||||
const esValue = this !== null && this !== undefined ? this : globalObject;
|
||||
|
||||
if (!exports.is(esValue)) {
|
||||
throw new TypeError("Illegal invocation");
|
||||
}
|
||||
|
||||
return esValue[implSymbol]["data"];
|
||||
}
|
||||
}
|
||||
Object.defineProperties(CompositionEvent.prototype, {
|
||||
initCompositionEvent: { enumerable: true },
|
||||
data: { enumerable: true },
|
||||
[Symbol.toStringTag]: { value: "CompositionEvent", configurable: true }
|
||||
});
|
||||
if (globalObject[ctorRegistrySymbol] === undefined) {
|
||||
globalObject[ctorRegistrySymbol] = Object.create(null);
|
||||
}
|
||||
globalObject[ctorRegistrySymbol][interfaceName] = CompositionEvent;
|
||||
|
||||
Object.defineProperty(globalObject, interfaceName, {
|
||||
configurable: true,
|
||||
writable: true,
|
||||
value: CompositionEvent
|
||||
});
|
||||
};
|
||||
|
||||
const Impl = require("../events/CompositionEvent-impl.js");
|
||||
|
||||
42
node_modules/jsdom/lib/jsdom/living/generated/CompositionEventInit.js
generated
vendored
42
node_modules/jsdom/lib/jsdom/living/generated/CompositionEventInit.js
generated
vendored
@@ -5,30 +5,28 @@ const utils = require("./utils.js");
|
||||
|
||||
const UIEventInit = require("./UIEventInit.js");
|
||||
|
||||
module.exports = {
|
||||
convertInherit(obj, ret, { context = "The provided value" } = {}) {
|
||||
UIEventInit.convertInherit(obj, ret, { context });
|
||||
exports._convertInherit = (obj, ret, { context = "The provided value" } = {}) => {
|
||||
UIEventInit._convertInherit(obj, ret, { context });
|
||||
|
||||
{
|
||||
const key = "data";
|
||||
let value = obj === undefined || obj === null ? undefined : obj[key];
|
||||
if (value !== undefined) {
|
||||
value = conversions["DOMString"](value, { context: context + " has member data that" });
|
||||
{
|
||||
const key = "data";
|
||||
let value = obj === undefined || obj === null ? undefined : obj[key];
|
||||
if (value !== undefined) {
|
||||
value = conversions["DOMString"](value, { context: context + " has member 'data' that" });
|
||||
|
||||
ret[key] = value;
|
||||
} else {
|
||||
ret[key] = "";
|
||||
}
|
||||
ret[key] = value;
|
||||
} else {
|
||||
ret[key] = "";
|
||||
}
|
||||
},
|
||||
|
||||
convert(obj, { context = "The provided value" } = {}) {
|
||||
if (obj !== undefined && typeof obj !== "object" && typeof obj !== "function") {
|
||||
throw new TypeError(`${context} is not an object.`);
|
||||
}
|
||||
|
||||
const ret = Object.create(null);
|
||||
module.exports.convertInherit(obj, ret, { context });
|
||||
return ret;
|
||||
}
|
||||
};
|
||||
|
||||
exports.convert = function convert(obj, { context = "The provided value" } = {}) {
|
||||
if (obj !== undefined && typeof obj !== "object" && typeof obj !== "function") {
|
||||
throw new TypeError(`${context} is not an object.`);
|
||||
}
|
||||
|
||||
const ret = Object.create(null);
|
||||
exports._convertInherit(obj, ret, { context });
|
||||
return ret;
|
||||
};
|
||||
|
||||
237
node_modules/jsdom/lib/jsdom/living/generated/CustomElementRegistry.js
generated
vendored
Normal file
237
node_modules/jsdom/lib/jsdom/living/generated/CustomElementRegistry.js
generated
vendored
Normal file
@@ -0,0 +1,237 @@
|
||||
"use strict";
|
||||
|
||||
const conversions = require("webidl-conversions");
|
||||
const utils = require("./utils.js");
|
||||
|
||||
const ElementDefinitionOptions = require("./ElementDefinitionOptions.js");
|
||||
const ceReactionsPreSteps_helpers_custom_elements = require("../helpers/custom-elements.js").ceReactionsPreSteps;
|
||||
const ceReactionsPostSteps_helpers_custom_elements = require("../helpers/custom-elements.js").ceReactionsPostSteps;
|
||||
const Node = require("./Node.js");
|
||||
const implSymbol = utils.implSymbol;
|
||||
const ctorRegistrySymbol = utils.ctorRegistrySymbol;
|
||||
|
||||
const interfaceName = "CustomElementRegistry";
|
||||
|
||||
exports.is = value => {
|
||||
return utils.isObject(value) && utils.hasOwn(value, implSymbol) && value[implSymbol] instanceof Impl.implementation;
|
||||
};
|
||||
exports.isImpl = value => {
|
||||
return utils.isObject(value) && value instanceof Impl.implementation;
|
||||
};
|
||||
exports.convert = (value, { context = "The provided value" } = {}) => {
|
||||
if (exports.is(value)) {
|
||||
return utils.implForWrapper(value);
|
||||
}
|
||||
throw new TypeError(`${context} is not of type 'CustomElementRegistry'.`);
|
||||
};
|
||||
|
||||
function makeWrapper(globalObject) {
|
||||
if (globalObject[ctorRegistrySymbol] === undefined) {
|
||||
throw new Error("Internal error: invalid global object");
|
||||
}
|
||||
|
||||
const ctor = globalObject[ctorRegistrySymbol]["CustomElementRegistry"];
|
||||
if (ctor === undefined) {
|
||||
throw new Error("Internal error: constructor CustomElementRegistry is not installed on the passed global object");
|
||||
}
|
||||
|
||||
return Object.create(ctor.prototype);
|
||||
}
|
||||
|
||||
exports.create = (globalObject, constructorArgs, privateData) => {
|
||||
const wrapper = makeWrapper(globalObject);
|
||||
return exports.setup(wrapper, globalObject, constructorArgs, privateData);
|
||||
};
|
||||
|
||||
exports.createImpl = (globalObject, constructorArgs, privateData) => {
|
||||
const wrapper = exports.create(globalObject, constructorArgs, privateData);
|
||||
return utils.implForWrapper(wrapper);
|
||||
};
|
||||
|
||||
exports._internalSetup = (wrapper, globalObject) => {};
|
||||
|
||||
exports.setup = (wrapper, globalObject, constructorArgs = [], privateData = {}) => {
|
||||
privateData.wrapper = wrapper;
|
||||
|
||||
exports._internalSetup(wrapper, globalObject);
|
||||
Object.defineProperty(wrapper, implSymbol, {
|
||||
value: new Impl.implementation(globalObject, constructorArgs, privateData),
|
||||
configurable: true
|
||||
});
|
||||
|
||||
wrapper[implSymbol][utils.wrapperSymbol] = wrapper;
|
||||
if (Impl.init) {
|
||||
Impl.init(wrapper[implSymbol]);
|
||||
}
|
||||
return wrapper;
|
||||
};
|
||||
|
||||
exports.new = globalObject => {
|
||||
const wrapper = makeWrapper(globalObject);
|
||||
|
||||
exports._internalSetup(wrapper, globalObject);
|
||||
Object.defineProperty(wrapper, implSymbol, {
|
||||
value: Object.create(Impl.implementation.prototype),
|
||||
configurable: true
|
||||
});
|
||||
|
||||
wrapper[implSymbol][utils.wrapperSymbol] = wrapper;
|
||||
if (Impl.init) {
|
||||
Impl.init(wrapper[implSymbol]);
|
||||
}
|
||||
return wrapper[implSymbol];
|
||||
};
|
||||
|
||||
const exposed = new Set(["Window"]);
|
||||
|
||||
exports.install = (globalObject, globalNames) => {
|
||||
if (!globalNames.some(globalName => exposed.has(globalName))) {
|
||||
return;
|
||||
}
|
||||
class CustomElementRegistry {
|
||||
constructor() {
|
||||
throw new TypeError("Illegal constructor");
|
||||
}
|
||||
|
||||
define(name, constructor) {
|
||||
const esValue = this !== null && this !== undefined ? this : globalObject;
|
||||
if (!exports.is(esValue)) {
|
||||
throw new TypeError("Illegal invocation");
|
||||
}
|
||||
|
||||
if (arguments.length < 2) {
|
||||
throw new TypeError(
|
||||
"Failed to execute 'define' on 'CustomElementRegistry': 2 arguments required, but only " +
|
||||
arguments.length +
|
||||
" present."
|
||||
);
|
||||
}
|
||||
const args = [];
|
||||
{
|
||||
let curArg = arguments[0];
|
||||
curArg = conversions["DOMString"](curArg, {
|
||||
context: "Failed to execute 'define' on 'CustomElementRegistry': parameter 1"
|
||||
});
|
||||
args.push(curArg);
|
||||
}
|
||||
{
|
||||
let curArg = arguments[1];
|
||||
curArg = utils.tryImplForWrapper(curArg);
|
||||
args.push(curArg);
|
||||
}
|
||||
{
|
||||
let curArg = arguments[2];
|
||||
curArg = ElementDefinitionOptions.convert(curArg, {
|
||||
context: "Failed to execute 'define' on 'CustomElementRegistry': parameter 3"
|
||||
});
|
||||
args.push(curArg);
|
||||
}
|
||||
ceReactionsPreSteps_helpers_custom_elements(globalObject);
|
||||
try {
|
||||
return esValue[implSymbol].define(...args);
|
||||
} finally {
|
||||
ceReactionsPostSteps_helpers_custom_elements(globalObject);
|
||||
}
|
||||
}
|
||||
|
||||
get(name) {
|
||||
const esValue = this !== null && this !== undefined ? this : globalObject;
|
||||
if (!exports.is(esValue)) {
|
||||
throw new TypeError("Illegal invocation");
|
||||
}
|
||||
|
||||
if (arguments.length < 1) {
|
||||
throw new TypeError(
|
||||
"Failed to execute 'get' on 'CustomElementRegistry': 1 argument required, but only " +
|
||||
arguments.length +
|
||||
" present."
|
||||
);
|
||||
}
|
||||
const args = [];
|
||||
{
|
||||
let curArg = arguments[0];
|
||||
curArg = conversions["DOMString"](curArg, {
|
||||
context: "Failed to execute 'get' on 'CustomElementRegistry': parameter 1"
|
||||
});
|
||||
args.push(curArg);
|
||||
}
|
||||
return esValue[implSymbol].get(...args);
|
||||
}
|
||||
|
||||
whenDefined(name) {
|
||||
try {
|
||||
const esValue = this !== null && this !== undefined ? this : globalObject;
|
||||
if (!exports.is(esValue)) {
|
||||
throw new TypeError("Illegal invocation");
|
||||
}
|
||||
|
||||
if (arguments.length < 1) {
|
||||
throw new TypeError(
|
||||
"Failed to execute 'whenDefined' on 'CustomElementRegistry': 1 argument required, but only " +
|
||||
arguments.length +
|
||||
" present."
|
||||
);
|
||||
}
|
||||
const args = [];
|
||||
{
|
||||
let curArg = arguments[0];
|
||||
curArg = conversions["DOMString"](curArg, {
|
||||
context: "Failed to execute 'whenDefined' on 'CustomElementRegistry': parameter 1"
|
||||
});
|
||||
args.push(curArg);
|
||||
}
|
||||
return utils.tryWrapperForImpl(esValue[implSymbol].whenDefined(...args));
|
||||
} catch (e) {
|
||||
return Promise.reject(e);
|
||||
}
|
||||
}
|
||||
|
||||
upgrade(root) {
|
||||
const esValue = this !== null && this !== undefined ? this : globalObject;
|
||||
if (!exports.is(esValue)) {
|
||||
throw new TypeError("Illegal invocation");
|
||||
}
|
||||
|
||||
if (arguments.length < 1) {
|
||||
throw new TypeError(
|
||||
"Failed to execute 'upgrade' on 'CustomElementRegistry': 1 argument required, but only " +
|
||||
arguments.length +
|
||||
" present."
|
||||
);
|
||||
}
|
||||
const args = [];
|
||||
{
|
||||
let curArg = arguments[0];
|
||||
curArg = Node.convert(curArg, {
|
||||
context: "Failed to execute 'upgrade' on 'CustomElementRegistry': parameter 1"
|
||||
});
|
||||
args.push(curArg);
|
||||
}
|
||||
ceReactionsPreSteps_helpers_custom_elements(globalObject);
|
||||
try {
|
||||
return esValue[implSymbol].upgrade(...args);
|
||||
} finally {
|
||||
ceReactionsPostSteps_helpers_custom_elements(globalObject);
|
||||
}
|
||||
}
|
||||
}
|
||||
Object.defineProperties(CustomElementRegistry.prototype, {
|
||||
define: { enumerable: true },
|
||||
get: { enumerable: true },
|
||||
whenDefined: { enumerable: true },
|
||||
upgrade: { enumerable: true },
|
||||
[Symbol.toStringTag]: { value: "CustomElementRegistry", configurable: true }
|
||||
});
|
||||
if (globalObject[ctorRegistrySymbol] === undefined) {
|
||||
globalObject[ctorRegistrySymbol] = Object.create(null);
|
||||
}
|
||||
globalObject[ctorRegistrySymbol][interfaceName] = CustomElementRegistry;
|
||||
|
||||
Object.defineProperty(globalObject, interfaceName, {
|
||||
configurable: true,
|
||||
writable: true,
|
||||
value: CustomElementRegistry
|
||||
});
|
||||
};
|
||||
|
||||
const Impl = require("../custom-elements/CustomElementRegistry-impl.js");
|
||||
376
node_modules/jsdom/lib/jsdom/living/generated/CustomEvent.js
generated
vendored
376
node_modules/jsdom/lib/jsdom/living/generated/CustomEvent.js
generated
vendored
@@ -3,202 +3,198 @@
|
||||
const conversions = require("webidl-conversions");
|
||||
const utils = require("./utils.js");
|
||||
|
||||
const convertCustomEventInit = require("./CustomEventInit.js").convert;
|
||||
const impl = utils.implSymbol;
|
||||
const CustomEventInit = require("./CustomEventInit.js");
|
||||
const implSymbol = utils.implSymbol;
|
||||
const ctorRegistrySymbol = utils.ctorRegistrySymbol;
|
||||
const Event = require("./Event.js");
|
||||
|
||||
function CustomEvent(type) {
|
||||
if (new.target === undefined) {
|
||||
throw new TypeError(
|
||||
"Failed to construct 'CustomEvent'. Please use the 'new' operator; this constructor " +
|
||||
"cannot be called as a function."
|
||||
);
|
||||
}
|
||||
const interfaceName = "CustomEvent";
|
||||
|
||||
if (arguments.length < 1) {
|
||||
throw new TypeError(
|
||||
"Failed to construct 'CustomEvent': 1 argument required, but only " + arguments.length + " present."
|
||||
);
|
||||
exports.is = value => {
|
||||
return utils.isObject(value) && utils.hasOwn(value, implSymbol) && value[implSymbol] instanceof Impl.implementation;
|
||||
};
|
||||
exports.isImpl = value => {
|
||||
return utils.isObject(value) && value instanceof Impl.implementation;
|
||||
};
|
||||
exports.convert = (value, { context = "The provided value" } = {}) => {
|
||||
if (exports.is(value)) {
|
||||
return utils.implForWrapper(value);
|
||||
}
|
||||
const args = [];
|
||||
{
|
||||
let curArg = arguments[0];
|
||||
curArg = conversions["DOMString"](curArg, { context: "Failed to construct 'CustomEvent': parameter 1" });
|
||||
args.push(curArg);
|
||||
}
|
||||
{
|
||||
let curArg = arguments[1];
|
||||
curArg = convertCustomEventInit(curArg, { context: "Failed to construct 'CustomEvent': parameter 2" });
|
||||
args.push(curArg);
|
||||
}
|
||||
|
||||
iface.setup(this, args);
|
||||
}
|
||||
|
||||
Object.setPrototypeOf(CustomEvent.prototype, Event.interface.prototype);
|
||||
Object.setPrototypeOf(CustomEvent, Event.interface);
|
||||
|
||||
Object.defineProperty(CustomEvent, "prototype", {
|
||||
value: CustomEvent.prototype,
|
||||
writable: false,
|
||||
enumerable: false,
|
||||
configurable: false
|
||||
});
|
||||
|
||||
CustomEvent.prototype.initCustomEvent = function initCustomEvent(type) {
|
||||
if (!this || !module.exports.is(this)) {
|
||||
throw new TypeError("Illegal invocation");
|
||||
}
|
||||
|
||||
if (arguments.length < 1) {
|
||||
throw new TypeError(
|
||||
"Failed to execute 'initCustomEvent' on 'CustomEvent': 1 argument required, but only " +
|
||||
arguments.length +
|
||||
" present."
|
||||
);
|
||||
}
|
||||
const args = [];
|
||||
{
|
||||
let curArg = arguments[0];
|
||||
curArg = conversions["DOMString"](curArg, {
|
||||
context: "Failed to execute 'initCustomEvent' on 'CustomEvent': parameter 1"
|
||||
});
|
||||
args.push(curArg);
|
||||
}
|
||||
{
|
||||
let curArg = arguments[1];
|
||||
if (curArg !== undefined) {
|
||||
curArg = conversions["boolean"](curArg, {
|
||||
context: "Failed to execute 'initCustomEvent' on 'CustomEvent': parameter 2"
|
||||
});
|
||||
} else {
|
||||
curArg = false;
|
||||
}
|
||||
args.push(curArg);
|
||||
}
|
||||
{
|
||||
let curArg = arguments[2];
|
||||
if (curArg !== undefined) {
|
||||
curArg = conversions["boolean"](curArg, {
|
||||
context: "Failed to execute 'initCustomEvent' on 'CustomEvent': parameter 3"
|
||||
});
|
||||
} else {
|
||||
curArg = false;
|
||||
}
|
||||
args.push(curArg);
|
||||
}
|
||||
{
|
||||
let curArg = arguments[3];
|
||||
if (curArg !== undefined) {
|
||||
curArg = conversions["any"](curArg, {
|
||||
context: "Failed to execute 'initCustomEvent' on 'CustomEvent': parameter 4"
|
||||
});
|
||||
} else {
|
||||
curArg = null;
|
||||
}
|
||||
args.push(curArg);
|
||||
}
|
||||
return this[impl].initCustomEvent(...args);
|
||||
throw new TypeError(`${context} is not of type 'CustomEvent'.`);
|
||||
};
|
||||
|
||||
Object.defineProperty(CustomEvent.prototype, "detail", {
|
||||
get() {
|
||||
if (!this || !module.exports.is(this)) {
|
||||
throw new TypeError("Illegal invocation");
|
||||
}
|
||||
|
||||
return this[impl]["detail"];
|
||||
},
|
||||
|
||||
enumerable: true,
|
||||
configurable: true
|
||||
});
|
||||
|
||||
Object.defineProperty(CustomEvent.prototype, Symbol.toStringTag, {
|
||||
value: "CustomEvent",
|
||||
writable: false,
|
||||
enumerable: false,
|
||||
configurable: true
|
||||
});
|
||||
|
||||
const iface = {
|
||||
// When an interface-module that implements this interface as a mixin is loaded, it will append its own `.is()`
|
||||
// method into this array. It allows objects that directly implements *those* interfaces to be recognized as
|
||||
// implementing this mixin interface.
|
||||
_mixedIntoPredicates: [],
|
||||
is(obj) {
|
||||
if (obj) {
|
||||
if (utils.hasOwn(obj, impl) && obj[impl] instanceof Impl.implementation) {
|
||||
return true;
|
||||
}
|
||||
for (const isMixedInto of module.exports._mixedIntoPredicates) {
|
||||
if (isMixedInto(obj)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
},
|
||||
isImpl(obj) {
|
||||
if (obj) {
|
||||
if (obj instanceof Impl.implementation) {
|
||||
return true;
|
||||
}
|
||||
|
||||
const wrapper = utils.wrapperForImpl(obj);
|
||||
for (const isMixedInto of module.exports._mixedIntoPredicates) {
|
||||
if (isMixedInto(wrapper)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
},
|
||||
convert(obj, { context = "The provided value" } = {}) {
|
||||
if (module.exports.is(obj)) {
|
||||
return utils.implForWrapper(obj);
|
||||
}
|
||||
throw new TypeError(`${context} is not of type 'CustomEvent'.`);
|
||||
},
|
||||
|
||||
create(constructorArgs, privateData) {
|
||||
let obj = Object.create(CustomEvent.prototype);
|
||||
obj = this.setup(obj, constructorArgs, privateData);
|
||||
return obj;
|
||||
},
|
||||
createImpl(constructorArgs, privateData) {
|
||||
let obj = Object.create(CustomEvent.prototype);
|
||||
obj = this.setup(obj, constructorArgs, privateData);
|
||||
return utils.implForWrapper(obj);
|
||||
},
|
||||
_internalSetup(obj) {
|
||||
Event._internalSetup(obj);
|
||||
},
|
||||
setup(obj, constructorArgs, privateData) {
|
||||
if (!privateData) privateData = {};
|
||||
|
||||
privateData.wrapper = obj;
|
||||
|
||||
this._internalSetup(obj);
|
||||
Object.defineProperty(obj, impl, {
|
||||
value: new Impl.implementation(constructorArgs, privateData),
|
||||
writable: false,
|
||||
enumerable: false,
|
||||
configurable: true
|
||||
});
|
||||
|
||||
obj[impl][utils.wrapperSymbol] = obj;
|
||||
if (Impl.init) {
|
||||
Impl.init(obj[impl], privateData);
|
||||
}
|
||||
return obj;
|
||||
},
|
||||
interface: CustomEvent,
|
||||
expose: {
|
||||
Window: { CustomEvent },
|
||||
Worker: { CustomEvent }
|
||||
function makeWrapper(globalObject) {
|
||||
if (globalObject[ctorRegistrySymbol] === undefined) {
|
||||
throw new Error("Internal error: invalid global object");
|
||||
}
|
||||
}; // iface
|
||||
module.exports = iface;
|
||||
|
||||
const ctor = globalObject[ctorRegistrySymbol]["CustomEvent"];
|
||||
if (ctor === undefined) {
|
||||
throw new Error("Internal error: constructor CustomEvent is not installed on the passed global object");
|
||||
}
|
||||
|
||||
return Object.create(ctor.prototype);
|
||||
}
|
||||
|
||||
exports.create = (globalObject, constructorArgs, privateData) => {
|
||||
const wrapper = makeWrapper(globalObject);
|
||||
return exports.setup(wrapper, globalObject, constructorArgs, privateData);
|
||||
};
|
||||
|
||||
exports.createImpl = (globalObject, constructorArgs, privateData) => {
|
||||
const wrapper = exports.create(globalObject, constructorArgs, privateData);
|
||||
return utils.implForWrapper(wrapper);
|
||||
};
|
||||
|
||||
exports._internalSetup = (wrapper, globalObject) => {
|
||||
Event._internalSetup(wrapper, globalObject);
|
||||
};
|
||||
|
||||
exports.setup = (wrapper, globalObject, constructorArgs = [], privateData = {}) => {
|
||||
privateData.wrapper = wrapper;
|
||||
|
||||
exports._internalSetup(wrapper, globalObject);
|
||||
Object.defineProperty(wrapper, implSymbol, {
|
||||
value: new Impl.implementation(globalObject, constructorArgs, privateData),
|
||||
configurable: true
|
||||
});
|
||||
|
||||
wrapper[implSymbol][utils.wrapperSymbol] = wrapper;
|
||||
if (Impl.init) {
|
||||
Impl.init(wrapper[implSymbol]);
|
||||
}
|
||||
return wrapper;
|
||||
};
|
||||
|
||||
exports.new = globalObject => {
|
||||
const wrapper = makeWrapper(globalObject);
|
||||
|
||||
exports._internalSetup(wrapper, globalObject);
|
||||
Object.defineProperty(wrapper, implSymbol, {
|
||||
value: Object.create(Impl.implementation.prototype),
|
||||
configurable: true
|
||||
});
|
||||
|
||||
wrapper[implSymbol][utils.wrapperSymbol] = wrapper;
|
||||
if (Impl.init) {
|
||||
Impl.init(wrapper[implSymbol]);
|
||||
}
|
||||
return wrapper[implSymbol];
|
||||
};
|
||||
|
||||
const exposed = new Set(["Window", "Worker"]);
|
||||
|
||||
exports.install = (globalObject, globalNames) => {
|
||||
if (!globalNames.some(globalName => exposed.has(globalName))) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (globalObject.Event === undefined) {
|
||||
throw new Error("Internal error: attempting to evaluate CustomEvent before Event");
|
||||
}
|
||||
class CustomEvent extends globalObject.Event {
|
||||
constructor(type) {
|
||||
if (arguments.length < 1) {
|
||||
throw new TypeError(
|
||||
"Failed to construct 'CustomEvent': 1 argument required, but only " + arguments.length + " present."
|
||||
);
|
||||
}
|
||||
const args = [];
|
||||
{
|
||||
let curArg = arguments[0];
|
||||
curArg = conversions["DOMString"](curArg, { context: "Failed to construct 'CustomEvent': parameter 1" });
|
||||
args.push(curArg);
|
||||
}
|
||||
{
|
||||
let curArg = arguments[1];
|
||||
curArg = CustomEventInit.convert(curArg, { context: "Failed to construct 'CustomEvent': parameter 2" });
|
||||
args.push(curArg);
|
||||
}
|
||||
return exports.setup(Object.create(new.target.prototype), globalObject, args);
|
||||
}
|
||||
|
||||
initCustomEvent(type) {
|
||||
const esValue = this !== null && this !== undefined ? this : globalObject;
|
||||
if (!exports.is(esValue)) {
|
||||
throw new TypeError("Illegal invocation");
|
||||
}
|
||||
|
||||
if (arguments.length < 1) {
|
||||
throw new TypeError(
|
||||
"Failed to execute 'initCustomEvent' on 'CustomEvent': 1 argument required, but only " +
|
||||
arguments.length +
|
||||
" present."
|
||||
);
|
||||
}
|
||||
const args = [];
|
||||
{
|
||||
let curArg = arguments[0];
|
||||
curArg = conversions["DOMString"](curArg, {
|
||||
context: "Failed to execute 'initCustomEvent' on 'CustomEvent': parameter 1"
|
||||
});
|
||||
args.push(curArg);
|
||||
}
|
||||
{
|
||||
let curArg = arguments[1];
|
||||
if (curArg !== undefined) {
|
||||
curArg = conversions["boolean"](curArg, {
|
||||
context: "Failed to execute 'initCustomEvent' on 'CustomEvent': parameter 2"
|
||||
});
|
||||
} else {
|
||||
curArg = false;
|
||||
}
|
||||
args.push(curArg);
|
||||
}
|
||||
{
|
||||
let curArg = arguments[2];
|
||||
if (curArg !== undefined) {
|
||||
curArg = conversions["boolean"](curArg, {
|
||||
context: "Failed to execute 'initCustomEvent' on 'CustomEvent': parameter 3"
|
||||
});
|
||||
} else {
|
||||
curArg = false;
|
||||
}
|
||||
args.push(curArg);
|
||||
}
|
||||
{
|
||||
let curArg = arguments[3];
|
||||
if (curArg !== undefined) {
|
||||
curArg = conversions["any"](curArg, {
|
||||
context: "Failed to execute 'initCustomEvent' on 'CustomEvent': parameter 4"
|
||||
});
|
||||
} else {
|
||||
curArg = null;
|
||||
}
|
||||
args.push(curArg);
|
||||
}
|
||||
return esValue[implSymbol].initCustomEvent(...args);
|
||||
}
|
||||
|
||||
get detail() {
|
||||
const esValue = this !== null && this !== undefined ? this : globalObject;
|
||||
|
||||
if (!exports.is(esValue)) {
|
||||
throw new TypeError("Illegal invocation");
|
||||
}
|
||||
|
||||
return esValue[implSymbol]["detail"];
|
||||
}
|
||||
}
|
||||
Object.defineProperties(CustomEvent.prototype, {
|
||||
initCustomEvent: { enumerable: true },
|
||||
detail: { enumerable: true },
|
||||
[Symbol.toStringTag]: { value: "CustomEvent", configurable: true }
|
||||
});
|
||||
if (globalObject[ctorRegistrySymbol] === undefined) {
|
||||
globalObject[ctorRegistrySymbol] = Object.create(null);
|
||||
}
|
||||
globalObject[ctorRegistrySymbol][interfaceName] = CustomEvent;
|
||||
|
||||
Object.defineProperty(globalObject, interfaceName, {
|
||||
configurable: true,
|
||||
writable: true,
|
||||
value: CustomEvent
|
||||
});
|
||||
};
|
||||
|
||||
const Impl = require("../events/CustomEvent-impl.js");
|
||||
|
||||
42
node_modules/jsdom/lib/jsdom/living/generated/CustomEventInit.js
generated
vendored
42
node_modules/jsdom/lib/jsdom/living/generated/CustomEventInit.js
generated
vendored
@@ -5,30 +5,28 @@ const utils = require("./utils.js");
|
||||
|
||||
const EventInit = require("./EventInit.js");
|
||||
|
||||
module.exports = {
|
||||
convertInherit(obj, ret, { context = "The provided value" } = {}) {
|
||||
EventInit.convertInherit(obj, ret, { context });
|
||||
exports._convertInherit = (obj, ret, { context = "The provided value" } = {}) => {
|
||||
EventInit._convertInherit(obj, ret, { context });
|
||||
|
||||
{
|
||||
const key = "detail";
|
||||
let value = obj === undefined || obj === null ? undefined : obj[key];
|
||||
if (value !== undefined) {
|
||||
value = conversions["any"](value, { context: context + " has member detail that" });
|
||||
{
|
||||
const key = "detail";
|
||||
let value = obj === undefined || obj === null ? undefined : obj[key];
|
||||
if (value !== undefined) {
|
||||
value = conversions["any"](value, { context: context + " has member 'detail' that" });
|
||||
|
||||
ret[key] = value;
|
||||
} else {
|
||||
ret[key] = null;
|
||||
}
|
||||
ret[key] = value;
|
||||
} else {
|
||||
ret[key] = null;
|
||||
}
|
||||
},
|
||||
|
||||
convert(obj, { context = "The provided value" } = {}) {
|
||||
if (obj !== undefined && typeof obj !== "object" && typeof obj !== "function") {
|
||||
throw new TypeError(`${context} is not an object.`);
|
||||
}
|
||||
|
||||
const ret = Object.create(null);
|
||||
module.exports.convertInherit(obj, ret, { context });
|
||||
return ret;
|
||||
}
|
||||
};
|
||||
|
||||
exports.convert = function convert(obj, { context = "The provided value" } = {}) {
|
||||
if (obj !== undefined && typeof obj !== "object" && typeof obj !== "function") {
|
||||
throw new TypeError(`${context} is not an object.`);
|
||||
}
|
||||
|
||||
const ret = Object.create(null);
|
||||
exports._convertInherit(obj, ret, { context });
|
||||
return ret;
|
||||
};
|
||||
|
||||
386
node_modules/jsdom/lib/jsdom/living/generated/DOMImplementation.js
generated
vendored
386
node_modules/jsdom/lib/jsdom/living/generated/DOMImplementation.js
generated
vendored
@@ -3,214 +3,226 @@
|
||||
const conversions = require("webidl-conversions");
|
||||
const utils = require("./utils.js");
|
||||
|
||||
const convertDocumentType = require("./DocumentType.js").convert;
|
||||
const impl = utils.implSymbol;
|
||||
const DocumentType = require("./DocumentType.js");
|
||||
const implSymbol = utils.implSymbol;
|
||||
const ctorRegistrySymbol = utils.ctorRegistrySymbol;
|
||||
|
||||
function DOMImplementation() {
|
||||
throw new TypeError("Illegal constructor");
|
||||
const interfaceName = "DOMImplementation";
|
||||
|
||||
exports.is = value => {
|
||||
return utils.isObject(value) && utils.hasOwn(value, implSymbol) && value[implSymbol] instanceof Impl.implementation;
|
||||
};
|
||||
exports.isImpl = value => {
|
||||
return utils.isObject(value) && value instanceof Impl.implementation;
|
||||
};
|
||||
exports.convert = (value, { context = "The provided value" } = {}) => {
|
||||
if (exports.is(value)) {
|
||||
return utils.implForWrapper(value);
|
||||
}
|
||||
throw new TypeError(`${context} is not of type 'DOMImplementation'.`);
|
||||
};
|
||||
|
||||
function makeWrapper(globalObject) {
|
||||
if (globalObject[ctorRegistrySymbol] === undefined) {
|
||||
throw new Error("Internal error: invalid global object");
|
||||
}
|
||||
|
||||
const ctor = globalObject[ctorRegistrySymbol]["DOMImplementation"];
|
||||
if (ctor === undefined) {
|
||||
throw new Error("Internal error: constructor DOMImplementation is not installed on the passed global object");
|
||||
}
|
||||
|
||||
return Object.create(ctor.prototype);
|
||||
}
|
||||
|
||||
Object.defineProperty(DOMImplementation, "prototype", {
|
||||
value: DOMImplementation.prototype,
|
||||
writable: false,
|
||||
enumerable: false,
|
||||
configurable: false
|
||||
});
|
||||
|
||||
DOMImplementation.prototype.createDocumentType = function createDocumentType(qualifiedName, publicId, systemId) {
|
||||
if (!this || !module.exports.is(this)) {
|
||||
throw new TypeError("Illegal invocation");
|
||||
}
|
||||
|
||||
if (arguments.length < 3) {
|
||||
throw new TypeError(
|
||||
"Failed to execute 'createDocumentType' on 'DOMImplementation': 3 arguments required, but only " +
|
||||
arguments.length +
|
||||
" present."
|
||||
);
|
||||
}
|
||||
const args = [];
|
||||
{
|
||||
let curArg = arguments[0];
|
||||
curArg = conversions["DOMString"](curArg, {
|
||||
context: "Failed to execute 'createDocumentType' on 'DOMImplementation': parameter 1"
|
||||
});
|
||||
args.push(curArg);
|
||||
}
|
||||
{
|
||||
let curArg = arguments[1];
|
||||
curArg = conversions["DOMString"](curArg, {
|
||||
context: "Failed to execute 'createDocumentType' on 'DOMImplementation': parameter 2"
|
||||
});
|
||||
args.push(curArg);
|
||||
}
|
||||
{
|
||||
let curArg = arguments[2];
|
||||
curArg = conversions["DOMString"](curArg, {
|
||||
context: "Failed to execute 'createDocumentType' on 'DOMImplementation': parameter 3"
|
||||
});
|
||||
args.push(curArg);
|
||||
}
|
||||
return utils.tryWrapperForImpl(this[impl].createDocumentType(...args));
|
||||
exports.create = (globalObject, constructorArgs, privateData) => {
|
||||
const wrapper = makeWrapper(globalObject);
|
||||
return exports.setup(wrapper, globalObject, constructorArgs, privateData);
|
||||
};
|
||||
|
||||
DOMImplementation.prototype.createDocument = function createDocument(namespace, qualifiedName) {
|
||||
if (!this || !module.exports.is(this)) {
|
||||
throw new TypeError("Illegal invocation");
|
||||
}
|
||||
exports.createImpl = (globalObject, constructorArgs, privateData) => {
|
||||
const wrapper = exports.create(globalObject, constructorArgs, privateData);
|
||||
return utils.implForWrapper(wrapper);
|
||||
};
|
||||
|
||||
if (arguments.length < 2) {
|
||||
throw new TypeError(
|
||||
"Failed to execute 'createDocument' on 'DOMImplementation': 2 arguments required, but only " +
|
||||
arguments.length +
|
||||
" present."
|
||||
);
|
||||
exports._internalSetup = (wrapper, globalObject) => {};
|
||||
|
||||
exports.setup = (wrapper, globalObject, constructorArgs = [], privateData = {}) => {
|
||||
privateData.wrapper = wrapper;
|
||||
|
||||
exports._internalSetup(wrapper, globalObject);
|
||||
Object.defineProperty(wrapper, implSymbol, {
|
||||
value: new Impl.implementation(globalObject, constructorArgs, privateData),
|
||||
configurable: true
|
||||
});
|
||||
|
||||
wrapper[implSymbol][utils.wrapperSymbol] = wrapper;
|
||||
if (Impl.init) {
|
||||
Impl.init(wrapper[implSymbol]);
|
||||
}
|
||||
const args = [];
|
||||
{
|
||||
let curArg = arguments[0];
|
||||
if (curArg === null || curArg === undefined) {
|
||||
curArg = null;
|
||||
} else {
|
||||
curArg = conversions["DOMString"](curArg, {
|
||||
context: "Failed to execute 'createDocument' on 'DOMImplementation': parameter 1"
|
||||
});
|
||||
return wrapper;
|
||||
};
|
||||
|
||||
exports.new = globalObject => {
|
||||
const wrapper = makeWrapper(globalObject);
|
||||
|
||||
exports._internalSetup(wrapper, globalObject);
|
||||
Object.defineProperty(wrapper, implSymbol, {
|
||||
value: Object.create(Impl.implementation.prototype),
|
||||
configurable: true
|
||||
});
|
||||
|
||||
wrapper[implSymbol][utils.wrapperSymbol] = wrapper;
|
||||
if (Impl.init) {
|
||||
Impl.init(wrapper[implSymbol]);
|
||||
}
|
||||
return wrapper[implSymbol];
|
||||
};
|
||||
|
||||
const exposed = new Set(["Window"]);
|
||||
|
||||
exports.install = (globalObject, globalNames) => {
|
||||
if (!globalNames.some(globalName => exposed.has(globalName))) {
|
||||
return;
|
||||
}
|
||||
class DOMImplementation {
|
||||
constructor() {
|
||||
throw new TypeError("Illegal constructor");
|
||||
}
|
||||
args.push(curArg);
|
||||
}
|
||||
{
|
||||
let curArg = arguments[1];
|
||||
curArg = conversions["DOMString"](curArg, {
|
||||
context: "Failed to execute 'createDocument' on 'DOMImplementation': parameter 2",
|
||||
treatNullAsEmptyString: true
|
||||
});
|
||||
args.push(curArg);
|
||||
}
|
||||
{
|
||||
let curArg = arguments[2];
|
||||
if (curArg !== undefined) {
|
||||
if (curArg === null || curArg === undefined) {
|
||||
curArg = null;
|
||||
} else {
|
||||
curArg = convertDocumentType(curArg, {
|
||||
context: "Failed to execute 'createDocument' on 'DOMImplementation': parameter 3"
|
||||
|
||||
createDocumentType(qualifiedName, publicId, systemId) {
|
||||
const esValue = this !== null && this !== undefined ? this : globalObject;
|
||||
if (!exports.is(esValue)) {
|
||||
throw new TypeError("Illegal invocation");
|
||||
}
|
||||
|
||||
if (arguments.length < 3) {
|
||||
throw new TypeError(
|
||||
"Failed to execute 'createDocumentType' on 'DOMImplementation': 3 arguments required, but only " +
|
||||
arguments.length +
|
||||
" present."
|
||||
);
|
||||
}
|
||||
const args = [];
|
||||
{
|
||||
let curArg = arguments[0];
|
||||
curArg = conversions["DOMString"](curArg, {
|
||||
context: "Failed to execute 'createDocumentType' on 'DOMImplementation': parameter 1"
|
||||
});
|
||||
args.push(curArg);
|
||||
}
|
||||
} else {
|
||||
curArg = null;
|
||||
}
|
||||
args.push(curArg);
|
||||
}
|
||||
return utils.tryWrapperForImpl(this[impl].createDocument(...args));
|
||||
};
|
||||
|
||||
DOMImplementation.prototype.createHTMLDocument = function createHTMLDocument() {
|
||||
if (!this || !module.exports.is(this)) {
|
||||
throw new TypeError("Illegal invocation");
|
||||
}
|
||||
const args = [];
|
||||
{
|
||||
let curArg = arguments[0];
|
||||
if (curArg !== undefined) {
|
||||
curArg = conversions["DOMString"](curArg, {
|
||||
context: "Failed to execute 'createHTMLDocument' on 'DOMImplementation': parameter 1"
|
||||
});
|
||||
}
|
||||
args.push(curArg);
|
||||
}
|
||||
return utils.tryWrapperForImpl(this[impl].createHTMLDocument(...args));
|
||||
};
|
||||
|
||||
DOMImplementation.prototype.hasFeature = function hasFeature() {
|
||||
if (!this || !module.exports.is(this)) {
|
||||
throw new TypeError("Illegal invocation");
|
||||
}
|
||||
|
||||
return this[impl].hasFeature();
|
||||
};
|
||||
|
||||
Object.defineProperty(DOMImplementation.prototype, Symbol.toStringTag, {
|
||||
value: "DOMImplementation",
|
||||
writable: false,
|
||||
enumerable: false,
|
||||
configurable: true
|
||||
});
|
||||
|
||||
const iface = {
|
||||
// When an interface-module that implements this interface as a mixin is loaded, it will append its own `.is()`
|
||||
// method into this array. It allows objects that directly implements *those* interfaces to be recognized as
|
||||
// implementing this mixin interface.
|
||||
_mixedIntoPredicates: [],
|
||||
is(obj) {
|
||||
if (obj) {
|
||||
if (utils.hasOwn(obj, impl) && obj[impl] instanceof Impl.implementation) {
|
||||
return true;
|
||||
{
|
||||
let curArg = arguments[1];
|
||||
curArg = conversions["DOMString"](curArg, {
|
||||
context: "Failed to execute 'createDocumentType' on 'DOMImplementation': parameter 2"
|
||||
});
|
||||
args.push(curArg);
|
||||
}
|
||||
for (const isMixedInto of module.exports._mixedIntoPredicates) {
|
||||
if (isMixedInto(obj)) {
|
||||
return true;
|
||||
{
|
||||
let curArg = arguments[2];
|
||||
curArg = conversions["DOMString"](curArg, {
|
||||
context: "Failed to execute 'createDocumentType' on 'DOMImplementation': parameter 3"
|
||||
});
|
||||
args.push(curArg);
|
||||
}
|
||||
return utils.tryWrapperForImpl(esValue[implSymbol].createDocumentType(...args));
|
||||
}
|
||||
|
||||
createDocument(namespace, qualifiedName) {
|
||||
const esValue = this !== null && this !== undefined ? this : globalObject;
|
||||
if (!exports.is(esValue)) {
|
||||
throw new TypeError("Illegal invocation");
|
||||
}
|
||||
|
||||
if (arguments.length < 2) {
|
||||
throw new TypeError(
|
||||
"Failed to execute 'createDocument' on 'DOMImplementation': 2 arguments required, but only " +
|
||||
arguments.length +
|
||||
" present."
|
||||
);
|
||||
}
|
||||
const args = [];
|
||||
{
|
||||
let curArg = arguments[0];
|
||||
if (curArg === null || curArg === undefined) {
|
||||
curArg = null;
|
||||
} else {
|
||||
curArg = conversions["DOMString"](curArg, {
|
||||
context: "Failed to execute 'createDocument' on 'DOMImplementation': parameter 1"
|
||||
});
|
||||
}
|
||||
args.push(curArg);
|
||||
}
|
||||
}
|
||||
return false;
|
||||
},
|
||||
isImpl(obj) {
|
||||
if (obj) {
|
||||
if (obj instanceof Impl.implementation) {
|
||||
return true;
|
||||
{
|
||||
let curArg = arguments[1];
|
||||
curArg = conversions["DOMString"](curArg, {
|
||||
context: "Failed to execute 'createDocument' on 'DOMImplementation': parameter 2",
|
||||
treatNullAsEmptyString: true
|
||||
});
|
||||
args.push(curArg);
|
||||
}
|
||||
|
||||
const wrapper = utils.wrapperForImpl(obj);
|
||||
for (const isMixedInto of module.exports._mixedIntoPredicates) {
|
||||
if (isMixedInto(wrapper)) {
|
||||
return true;
|
||||
{
|
||||
let curArg = arguments[2];
|
||||
if (curArg !== undefined) {
|
||||
if (curArg === null || curArg === undefined) {
|
||||
curArg = null;
|
||||
} else {
|
||||
curArg = DocumentType.convert(curArg, {
|
||||
context: "Failed to execute 'createDocument' on 'DOMImplementation': parameter 3"
|
||||
});
|
||||
}
|
||||
} else {
|
||||
curArg = null;
|
||||
}
|
||||
args.push(curArg);
|
||||
}
|
||||
return utils.tryWrapperForImpl(esValue[implSymbol].createDocument(...args));
|
||||
}
|
||||
return false;
|
||||
},
|
||||
convert(obj, { context = "The provided value" } = {}) {
|
||||
if (module.exports.is(obj)) {
|
||||
return utils.implForWrapper(obj);
|
||||
|
||||
createHTMLDocument() {
|
||||
const esValue = this !== null && this !== undefined ? this : globalObject;
|
||||
if (!exports.is(esValue)) {
|
||||
throw new TypeError("Illegal invocation");
|
||||
}
|
||||
const args = [];
|
||||
{
|
||||
let curArg = arguments[0];
|
||||
if (curArg !== undefined) {
|
||||
curArg = conversions["DOMString"](curArg, {
|
||||
context: "Failed to execute 'createHTMLDocument' on 'DOMImplementation': parameter 1"
|
||||
});
|
||||
}
|
||||
args.push(curArg);
|
||||
}
|
||||
return utils.tryWrapperForImpl(esValue[implSymbol].createHTMLDocument(...args));
|
||||
}
|
||||
throw new TypeError(`${context} is not of type 'DOMImplementation'.`);
|
||||
},
|
||||
|
||||
create(constructorArgs, privateData) {
|
||||
let obj = Object.create(DOMImplementation.prototype);
|
||||
obj = this.setup(obj, constructorArgs, privateData);
|
||||
return obj;
|
||||
},
|
||||
createImpl(constructorArgs, privateData) {
|
||||
let obj = Object.create(DOMImplementation.prototype);
|
||||
obj = this.setup(obj, constructorArgs, privateData);
|
||||
return utils.implForWrapper(obj);
|
||||
},
|
||||
_internalSetup(obj) {},
|
||||
setup(obj, constructorArgs, privateData) {
|
||||
if (!privateData) privateData = {};
|
||||
hasFeature() {
|
||||
const esValue = this !== null && this !== undefined ? this : globalObject;
|
||||
if (!exports.is(esValue)) {
|
||||
throw new TypeError("Illegal invocation");
|
||||
}
|
||||
|
||||
privateData.wrapper = obj;
|
||||
|
||||
this._internalSetup(obj);
|
||||
Object.defineProperty(obj, impl, {
|
||||
value: new Impl.implementation(constructorArgs, privateData),
|
||||
writable: false,
|
||||
enumerable: false,
|
||||
configurable: true
|
||||
});
|
||||
|
||||
obj[impl][utils.wrapperSymbol] = obj;
|
||||
if (Impl.init) {
|
||||
Impl.init(obj[impl], privateData);
|
||||
return esValue[implSymbol].hasFeature();
|
||||
}
|
||||
return obj;
|
||||
},
|
||||
interface: DOMImplementation,
|
||||
expose: {
|
||||
Window: { DOMImplementation }
|
||||
}
|
||||
}; // iface
|
||||
module.exports = iface;
|
||||
Object.defineProperties(DOMImplementation.prototype, {
|
||||
createDocumentType: { enumerable: true },
|
||||
createDocument: { enumerable: true },
|
||||
createHTMLDocument: { enumerable: true },
|
||||
hasFeature: { enumerable: true },
|
||||
[Symbol.toStringTag]: { value: "DOMImplementation", configurable: true }
|
||||
});
|
||||
if (globalObject[ctorRegistrySymbol] === undefined) {
|
||||
globalObject[ctorRegistrySymbol] = Object.create(null);
|
||||
}
|
||||
globalObject[ctorRegistrySymbol][interfaceName] = DOMImplementation;
|
||||
|
||||
Object.defineProperty(globalObject, interfaceName, {
|
||||
configurable: true,
|
||||
writable: true,
|
||||
value: DOMImplementation
|
||||
});
|
||||
};
|
||||
|
||||
const Impl = require("../nodes/DOMImplementation-impl.js");
|
||||
|
||||
255
node_modules/jsdom/lib/jsdom/living/generated/DOMParser.js
generated
vendored
255
node_modules/jsdom/lib/jsdom/living/generated/DOMParser.js
generated
vendored
@@ -3,139 +3,138 @@
|
||||
const conversions = require("webidl-conversions");
|
||||
const utils = require("./utils.js");
|
||||
|
||||
const convertSupportedType = require("./SupportedType.js").convert;
|
||||
const impl = utils.implSymbol;
|
||||
const SupportedType = require("./SupportedType.js");
|
||||
const implSymbol = utils.implSymbol;
|
||||
const ctorRegistrySymbol = utils.ctorRegistrySymbol;
|
||||
|
||||
function DOMParser() {
|
||||
if (new.target === undefined) {
|
||||
throw new TypeError(
|
||||
"Failed to construct 'DOMParser'. Please use the 'new' operator; this constructor " +
|
||||
"cannot be called as a function."
|
||||
);
|
||||
}
|
||||
const interfaceName = "DOMParser";
|
||||
|
||||
iface.setup(this);
|
||||
}
|
||||
|
||||
Object.defineProperty(DOMParser, "prototype", {
|
||||
value: DOMParser.prototype,
|
||||
writable: false,
|
||||
enumerable: false,
|
||||
configurable: false
|
||||
});
|
||||
|
||||
DOMParser.prototype.parseFromString = function parseFromString(str, type) {
|
||||
if (!this || !module.exports.is(this)) {
|
||||
throw new TypeError("Illegal invocation");
|
||||
exports.is = value => {
|
||||
return utils.isObject(value) && utils.hasOwn(value, implSymbol) && value[implSymbol] instanceof Impl.implementation;
|
||||
};
|
||||
exports.isImpl = value => {
|
||||
return utils.isObject(value) && value instanceof Impl.implementation;
|
||||
};
|
||||
exports.convert = (value, { context = "The provided value" } = {}) => {
|
||||
if (exports.is(value)) {
|
||||
return utils.implForWrapper(value);
|
||||
}
|
||||
|
||||
if (arguments.length < 2) {
|
||||
throw new TypeError(
|
||||
"Failed to execute 'parseFromString' on 'DOMParser': 2 arguments required, but only " +
|
||||
arguments.length +
|
||||
" present."
|
||||
);
|
||||
}
|
||||
const args = [];
|
||||
{
|
||||
let curArg = arguments[0];
|
||||
curArg = conversions["DOMString"](curArg, {
|
||||
context: "Failed to execute 'parseFromString' on 'DOMParser': parameter 1"
|
||||
});
|
||||
args.push(curArg);
|
||||
}
|
||||
{
|
||||
let curArg = arguments[1];
|
||||
curArg = convertSupportedType(curArg, {
|
||||
context: "Failed to execute 'parseFromString' on 'DOMParser': parameter 2"
|
||||
});
|
||||
args.push(curArg);
|
||||
}
|
||||
return utils.tryWrapperForImpl(this[impl].parseFromString(...args));
|
||||
throw new TypeError(`${context} is not of type 'DOMParser'.`);
|
||||
};
|
||||
|
||||
Object.defineProperty(DOMParser.prototype, Symbol.toStringTag, {
|
||||
value: "DOMParser",
|
||||
writable: false,
|
||||
enumerable: false,
|
||||
configurable: true
|
||||
});
|
||||
|
||||
const iface = {
|
||||
// When an interface-module that implements this interface as a mixin is loaded, it will append its own `.is()`
|
||||
// method into this array. It allows objects that directly implements *those* interfaces to be recognized as
|
||||
// implementing this mixin interface.
|
||||
_mixedIntoPredicates: [],
|
||||
is(obj) {
|
||||
if (obj) {
|
||||
if (utils.hasOwn(obj, impl) && obj[impl] instanceof Impl.implementation) {
|
||||
return true;
|
||||
}
|
||||
for (const isMixedInto of module.exports._mixedIntoPredicates) {
|
||||
if (isMixedInto(obj)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
},
|
||||
isImpl(obj) {
|
||||
if (obj) {
|
||||
if (obj instanceof Impl.implementation) {
|
||||
return true;
|
||||
}
|
||||
|
||||
const wrapper = utils.wrapperForImpl(obj);
|
||||
for (const isMixedInto of module.exports._mixedIntoPredicates) {
|
||||
if (isMixedInto(wrapper)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
},
|
||||
convert(obj, { context = "The provided value" } = {}) {
|
||||
if (module.exports.is(obj)) {
|
||||
return utils.implForWrapper(obj);
|
||||
}
|
||||
throw new TypeError(`${context} is not of type 'DOMParser'.`);
|
||||
},
|
||||
|
||||
create(constructorArgs, privateData) {
|
||||
let obj = Object.create(DOMParser.prototype);
|
||||
obj = this.setup(obj, constructorArgs, privateData);
|
||||
return obj;
|
||||
},
|
||||
createImpl(constructorArgs, privateData) {
|
||||
let obj = Object.create(DOMParser.prototype);
|
||||
obj = this.setup(obj, constructorArgs, privateData);
|
||||
return utils.implForWrapper(obj);
|
||||
},
|
||||
_internalSetup(obj) {},
|
||||
setup(obj, constructorArgs, privateData) {
|
||||
if (!privateData) privateData = {};
|
||||
|
||||
privateData.wrapper = obj;
|
||||
|
||||
this._internalSetup(obj);
|
||||
Object.defineProperty(obj, impl, {
|
||||
value: new Impl.implementation(constructorArgs, privateData),
|
||||
writable: false,
|
||||
enumerable: false,
|
||||
configurable: true
|
||||
});
|
||||
|
||||
obj[impl][utils.wrapperSymbol] = obj;
|
||||
if (Impl.init) {
|
||||
Impl.init(obj[impl], privateData);
|
||||
}
|
||||
return obj;
|
||||
},
|
||||
interface: DOMParser,
|
||||
expose: {
|
||||
Window: { DOMParser }
|
||||
function makeWrapper(globalObject) {
|
||||
if (globalObject[ctorRegistrySymbol] === undefined) {
|
||||
throw new Error("Internal error: invalid global object");
|
||||
}
|
||||
}; // iface
|
||||
module.exports = iface;
|
||||
|
||||
const ctor = globalObject[ctorRegistrySymbol]["DOMParser"];
|
||||
if (ctor === undefined) {
|
||||
throw new Error("Internal error: constructor DOMParser is not installed on the passed global object");
|
||||
}
|
||||
|
||||
return Object.create(ctor.prototype);
|
||||
}
|
||||
|
||||
exports.create = (globalObject, constructorArgs, privateData) => {
|
||||
const wrapper = makeWrapper(globalObject);
|
||||
return exports.setup(wrapper, globalObject, constructorArgs, privateData);
|
||||
};
|
||||
|
||||
exports.createImpl = (globalObject, constructorArgs, privateData) => {
|
||||
const wrapper = exports.create(globalObject, constructorArgs, privateData);
|
||||
return utils.implForWrapper(wrapper);
|
||||
};
|
||||
|
||||
exports._internalSetup = (wrapper, globalObject) => {};
|
||||
|
||||
exports.setup = (wrapper, globalObject, constructorArgs = [], privateData = {}) => {
|
||||
privateData.wrapper = wrapper;
|
||||
|
||||
exports._internalSetup(wrapper, globalObject);
|
||||
Object.defineProperty(wrapper, implSymbol, {
|
||||
value: new Impl.implementation(globalObject, constructorArgs, privateData),
|
||||
configurable: true
|
||||
});
|
||||
|
||||
wrapper[implSymbol][utils.wrapperSymbol] = wrapper;
|
||||
if (Impl.init) {
|
||||
Impl.init(wrapper[implSymbol]);
|
||||
}
|
||||
return wrapper;
|
||||
};
|
||||
|
||||
exports.new = globalObject => {
|
||||
const wrapper = makeWrapper(globalObject);
|
||||
|
||||
exports._internalSetup(wrapper, globalObject);
|
||||
Object.defineProperty(wrapper, implSymbol, {
|
||||
value: Object.create(Impl.implementation.prototype),
|
||||
configurable: true
|
||||
});
|
||||
|
||||
wrapper[implSymbol][utils.wrapperSymbol] = wrapper;
|
||||
if (Impl.init) {
|
||||
Impl.init(wrapper[implSymbol]);
|
||||
}
|
||||
return wrapper[implSymbol];
|
||||
};
|
||||
|
||||
const exposed = new Set(["Window"]);
|
||||
|
||||
exports.install = (globalObject, globalNames) => {
|
||||
if (!globalNames.some(globalName => exposed.has(globalName))) {
|
||||
return;
|
||||
}
|
||||
class DOMParser {
|
||||
constructor() {
|
||||
return exports.setup(Object.create(new.target.prototype), globalObject, undefined);
|
||||
}
|
||||
|
||||
parseFromString(str, type) {
|
||||
const esValue = this !== null && this !== undefined ? this : globalObject;
|
||||
if (!exports.is(esValue)) {
|
||||
throw new TypeError("Illegal invocation");
|
||||
}
|
||||
|
||||
if (arguments.length < 2) {
|
||||
throw new TypeError(
|
||||
"Failed to execute 'parseFromString' on 'DOMParser': 2 arguments required, but only " +
|
||||
arguments.length +
|
||||
" present."
|
||||
);
|
||||
}
|
||||
const args = [];
|
||||
{
|
||||
let curArg = arguments[0];
|
||||
curArg = conversions["DOMString"](curArg, {
|
||||
context: "Failed to execute 'parseFromString' on 'DOMParser': parameter 1"
|
||||
});
|
||||
args.push(curArg);
|
||||
}
|
||||
{
|
||||
let curArg = arguments[1];
|
||||
curArg = SupportedType.convert(curArg, {
|
||||
context: "Failed to execute 'parseFromString' on 'DOMParser': parameter 2"
|
||||
});
|
||||
args.push(curArg);
|
||||
}
|
||||
return utils.tryWrapperForImpl(esValue[implSymbol].parseFromString(...args));
|
||||
}
|
||||
}
|
||||
Object.defineProperties(DOMParser.prototype, {
|
||||
parseFromString: { enumerable: true },
|
||||
[Symbol.toStringTag]: { value: "DOMParser", configurable: true }
|
||||
});
|
||||
if (globalObject[ctorRegistrySymbol] === undefined) {
|
||||
globalObject[ctorRegistrySymbol] = Object.create(null);
|
||||
}
|
||||
globalObject[ctorRegistrySymbol][interfaceName] = DOMParser;
|
||||
|
||||
Object.defineProperty(globalObject, interfaceName, {
|
||||
configurable: true,
|
||||
writable: true,
|
||||
value: DOMParser
|
||||
});
|
||||
};
|
||||
|
||||
const Impl = require("../domparsing/DOMParser-impl.js");
|
||||
|
||||
515
node_modules/jsdom/lib/jsdom/living/generated/DOMStringMap.js
generated
vendored
515
node_modules/jsdom/lib/jsdom/living/generated/DOMStringMap.js
generated
vendored
@@ -3,273 +3,318 @@
|
||||
const conversions = require("webidl-conversions");
|
||||
const utils = require("./utils.js");
|
||||
|
||||
const impl = utils.implSymbol;
|
||||
const ceReactionsPreSteps_helpers_custom_elements = require("../helpers/custom-elements.js").ceReactionsPreSteps;
|
||||
const ceReactionsPostSteps_helpers_custom_elements = require("../helpers/custom-elements.js").ceReactionsPostSteps;
|
||||
const implSymbol = utils.implSymbol;
|
||||
const ctorRegistrySymbol = utils.ctorRegistrySymbol;
|
||||
|
||||
function DOMStringMap() {
|
||||
throw new TypeError("Illegal constructor");
|
||||
const interfaceName = "DOMStringMap";
|
||||
|
||||
exports.is = value => {
|
||||
return utils.isObject(value) && utils.hasOwn(value, implSymbol) && value[implSymbol] instanceof Impl.implementation;
|
||||
};
|
||||
exports.isImpl = value => {
|
||||
return utils.isObject(value) && value instanceof Impl.implementation;
|
||||
};
|
||||
exports.convert = (value, { context = "The provided value" } = {}) => {
|
||||
if (exports.is(value)) {
|
||||
return utils.implForWrapper(value);
|
||||
}
|
||||
throw new TypeError(`${context} is not of type 'DOMStringMap'.`);
|
||||
};
|
||||
|
||||
function makeWrapper(globalObject) {
|
||||
if (globalObject[ctorRegistrySymbol] === undefined) {
|
||||
throw new Error("Internal error: invalid global object");
|
||||
}
|
||||
|
||||
const ctor = globalObject[ctorRegistrySymbol]["DOMStringMap"];
|
||||
if (ctor === undefined) {
|
||||
throw new Error("Internal error: constructor DOMStringMap is not installed on the passed global object");
|
||||
}
|
||||
|
||||
return Object.create(ctor.prototype);
|
||||
}
|
||||
|
||||
Object.defineProperty(DOMStringMap, "prototype", {
|
||||
value: DOMStringMap.prototype,
|
||||
writable: false,
|
||||
enumerable: false,
|
||||
configurable: false
|
||||
});
|
||||
function makeProxy(wrapper, globalObject) {
|
||||
let proxyHandler = proxyHandlerCache.get(globalObject);
|
||||
if (proxyHandler === undefined) {
|
||||
proxyHandler = new ProxyHandler(globalObject);
|
||||
proxyHandlerCache.set(globalObject, proxyHandler);
|
||||
}
|
||||
return new Proxy(wrapper, proxyHandler);
|
||||
}
|
||||
|
||||
Object.defineProperty(DOMStringMap.prototype, Symbol.toStringTag, {
|
||||
value: "DOMStringMap",
|
||||
writable: false,
|
||||
enumerable: false,
|
||||
configurable: true
|
||||
});
|
||||
exports.create = (globalObject, constructorArgs, privateData) => {
|
||||
const wrapper = makeWrapper(globalObject);
|
||||
return exports.setup(wrapper, globalObject, constructorArgs, privateData);
|
||||
};
|
||||
|
||||
const iface = {
|
||||
// When an interface-module that implements this interface as a mixin is loaded, it will append its own `.is()`
|
||||
// method into this array. It allows objects that directly implements *those* interfaces to be recognized as
|
||||
// implementing this mixin interface.
|
||||
_mixedIntoPredicates: [],
|
||||
is(obj) {
|
||||
if (obj) {
|
||||
if (utils.hasOwn(obj, impl) && obj[impl] instanceof Impl.implementation) {
|
||||
return true;
|
||||
}
|
||||
for (const isMixedInto of module.exports._mixedIntoPredicates) {
|
||||
if (isMixedInto(obj)) {
|
||||
return true;
|
||||
}
|
||||
exports.createImpl = (globalObject, constructorArgs, privateData) => {
|
||||
const wrapper = exports.create(globalObject, constructorArgs, privateData);
|
||||
return utils.implForWrapper(wrapper);
|
||||
};
|
||||
|
||||
exports._internalSetup = (wrapper, globalObject) => {};
|
||||
|
||||
exports.setup = (wrapper, globalObject, constructorArgs = [], privateData = {}) => {
|
||||
privateData.wrapper = wrapper;
|
||||
|
||||
exports._internalSetup(wrapper, globalObject);
|
||||
Object.defineProperty(wrapper, implSymbol, {
|
||||
value: new Impl.implementation(globalObject, constructorArgs, privateData),
|
||||
configurable: true
|
||||
});
|
||||
|
||||
wrapper = makeProxy(wrapper, globalObject);
|
||||
|
||||
wrapper[implSymbol][utils.wrapperSymbol] = wrapper;
|
||||
if (Impl.init) {
|
||||
Impl.init(wrapper[implSymbol]);
|
||||
}
|
||||
return wrapper;
|
||||
};
|
||||
|
||||
exports.new = globalObject => {
|
||||
let wrapper = makeWrapper(globalObject);
|
||||
|
||||
exports._internalSetup(wrapper, globalObject);
|
||||
Object.defineProperty(wrapper, implSymbol, {
|
||||
value: Object.create(Impl.implementation.prototype),
|
||||
configurable: true
|
||||
});
|
||||
|
||||
wrapper = makeProxy(wrapper, globalObject);
|
||||
|
||||
wrapper[implSymbol][utils.wrapperSymbol] = wrapper;
|
||||
if (Impl.init) {
|
||||
Impl.init(wrapper[implSymbol]);
|
||||
}
|
||||
return wrapper[implSymbol];
|
||||
};
|
||||
|
||||
const exposed = new Set(["Window"]);
|
||||
|
||||
exports.install = (globalObject, globalNames) => {
|
||||
if (!globalNames.some(globalName => exposed.has(globalName))) {
|
||||
return;
|
||||
}
|
||||
class DOMStringMap {
|
||||
constructor() {
|
||||
throw new TypeError("Illegal constructor");
|
||||
}
|
||||
}
|
||||
Object.defineProperties(DOMStringMap.prototype, {
|
||||
[Symbol.toStringTag]: { value: "DOMStringMap", configurable: true }
|
||||
});
|
||||
if (globalObject[ctorRegistrySymbol] === undefined) {
|
||||
globalObject[ctorRegistrySymbol] = Object.create(null);
|
||||
}
|
||||
globalObject[ctorRegistrySymbol][interfaceName] = DOMStringMap;
|
||||
|
||||
Object.defineProperty(globalObject, interfaceName, {
|
||||
configurable: true,
|
||||
writable: true,
|
||||
value: DOMStringMap
|
||||
});
|
||||
};
|
||||
|
||||
const proxyHandlerCache = new WeakMap();
|
||||
class ProxyHandler {
|
||||
constructor(globalObject) {
|
||||
this._globalObject = globalObject;
|
||||
}
|
||||
|
||||
get(target, P, receiver) {
|
||||
if (typeof P === "symbol") {
|
||||
return Reflect.get(target, P, receiver);
|
||||
}
|
||||
const desc = this.getOwnPropertyDescriptor(target, P);
|
||||
if (desc === undefined) {
|
||||
const parent = Object.getPrototypeOf(target);
|
||||
if (parent === null) {
|
||||
return undefined;
|
||||
}
|
||||
return Reflect.get(target, P, receiver);
|
||||
}
|
||||
if (!desc.get && !desc.set) {
|
||||
return desc.value;
|
||||
}
|
||||
const getter = desc.get;
|
||||
if (getter === undefined) {
|
||||
return undefined;
|
||||
}
|
||||
return Reflect.apply(getter, receiver, []);
|
||||
}
|
||||
|
||||
has(target, P) {
|
||||
if (typeof P === "symbol") {
|
||||
return Reflect.has(target, P);
|
||||
}
|
||||
const desc = this.getOwnPropertyDescriptor(target, P);
|
||||
if (desc !== undefined) {
|
||||
return true;
|
||||
}
|
||||
const parent = Object.getPrototypeOf(target);
|
||||
if (parent !== null) {
|
||||
return Reflect.has(parent, P);
|
||||
}
|
||||
return false;
|
||||
},
|
||||
isImpl(obj) {
|
||||
if (obj) {
|
||||
if (obj instanceof Impl.implementation) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
const wrapper = utils.wrapperForImpl(obj);
|
||||
for (const isMixedInto of module.exports._mixedIntoPredicates) {
|
||||
if (isMixedInto(wrapper)) {
|
||||
return true;
|
||||
}
|
||||
ownKeys(target) {
|
||||
const keys = new Set();
|
||||
|
||||
for (const key of target[implSymbol][utils.supportedPropertyNames]) {
|
||||
if (!utils.hasOwn(target, key)) {
|
||||
keys.add(`${key}`);
|
||||
}
|
||||
}
|
||||
return false;
|
||||
},
|
||||
convert(obj, { context = "The provided value" } = {}) {
|
||||
if (module.exports.is(obj)) {
|
||||
return utils.implForWrapper(obj);
|
||||
|
||||
for (const key of Reflect.ownKeys(target)) {
|
||||
keys.add(key);
|
||||
}
|
||||
throw new TypeError(`${context} is not of type 'DOMStringMap'.`);
|
||||
},
|
||||
return [...keys];
|
||||
}
|
||||
|
||||
create(constructorArgs, privateData) {
|
||||
let obj = Object.create(DOMStringMap.prototype);
|
||||
obj = this.setup(obj, constructorArgs, privateData);
|
||||
return obj;
|
||||
},
|
||||
createImpl(constructorArgs, privateData) {
|
||||
let obj = Object.create(DOMStringMap.prototype);
|
||||
obj = this.setup(obj, constructorArgs, privateData);
|
||||
return utils.implForWrapper(obj);
|
||||
},
|
||||
_internalSetup(obj) {},
|
||||
setup(obj, constructorArgs, privateData) {
|
||||
if (!privateData) privateData = {};
|
||||
getOwnPropertyDescriptor(target, P) {
|
||||
if (typeof P === "symbol") {
|
||||
return Reflect.getOwnPropertyDescriptor(target, P);
|
||||
}
|
||||
let ignoreNamedProps = false;
|
||||
|
||||
privateData.wrapper = obj;
|
||||
const namedValue = target[implSymbol][utils.namedGet](P);
|
||||
|
||||
this._internalSetup(obj);
|
||||
Object.defineProperty(obj, impl, {
|
||||
value: new Impl.implementation(constructorArgs, privateData),
|
||||
writable: false,
|
||||
enumerable: false,
|
||||
configurable: true
|
||||
});
|
||||
if (namedValue !== undefined && !utils.hasOwn(target, P) && !ignoreNamedProps) {
|
||||
return {
|
||||
writable: true,
|
||||
enumerable: true,
|
||||
configurable: true,
|
||||
value: utils.tryWrapperForImpl(namedValue)
|
||||
};
|
||||
}
|
||||
|
||||
obj = new Proxy(obj, {
|
||||
get(target, P, receiver) {
|
||||
if (typeof P === "symbol") {
|
||||
return Reflect.get(target, P, receiver);
|
||||
}
|
||||
const desc = this.getOwnPropertyDescriptor(target, P);
|
||||
if (desc === undefined) {
|
||||
const parent = Object.getPrototypeOf(target);
|
||||
if (parent === null) {
|
||||
return undefined;
|
||||
}
|
||||
return Reflect.get(target, P, receiver);
|
||||
}
|
||||
if (!desc.get && !desc.set) {
|
||||
return desc.value;
|
||||
}
|
||||
const getter = desc.get;
|
||||
if (getter === undefined) {
|
||||
return undefined;
|
||||
}
|
||||
return Reflect.apply(getter, receiver, []);
|
||||
},
|
||||
return Reflect.getOwnPropertyDescriptor(target, P);
|
||||
}
|
||||
|
||||
has(target, P) {
|
||||
if (typeof P === "symbol") {
|
||||
return Reflect.has(target, P);
|
||||
}
|
||||
const desc = this.getOwnPropertyDescriptor(target, P);
|
||||
if (desc !== undefined) {
|
||||
return true;
|
||||
}
|
||||
const parent = Object.getPrototypeOf(target);
|
||||
if (parent !== null) {
|
||||
return Reflect.has(parent, P);
|
||||
}
|
||||
return false;
|
||||
},
|
||||
set(target, P, V, receiver) {
|
||||
if (typeof P === "symbol") {
|
||||
return Reflect.set(target, P, V, receiver);
|
||||
}
|
||||
if (target === receiver) {
|
||||
const globalObject = this._globalObject;
|
||||
|
||||
ownKeys(target) {
|
||||
const keys = new Set();
|
||||
|
||||
for (const key of target[impl][utils.supportedPropertyNames]) {
|
||||
if (!utils.hasOwn(target, key)) {
|
||||
keys.add(`${key}`);
|
||||
}
|
||||
}
|
||||
|
||||
for (const key of Reflect.ownKeys(target)) {
|
||||
keys.add(key);
|
||||
}
|
||||
return [...keys];
|
||||
},
|
||||
|
||||
getOwnPropertyDescriptor(target, P) {
|
||||
if (typeof P === "symbol") {
|
||||
return Reflect.getOwnPropertyDescriptor(target, P);
|
||||
}
|
||||
let ignoreNamedProps = false;
|
||||
|
||||
const namedValue = target[impl][utils.namedGet](P);
|
||||
|
||||
if (namedValue !== undefined && !utils.hasOwn(target, P) && !ignoreNamedProps) {
|
||||
return {
|
||||
writable: true,
|
||||
enumerable: true,
|
||||
configurable: true,
|
||||
value: utils.tryWrapperForImpl(namedValue)
|
||||
};
|
||||
}
|
||||
|
||||
return Reflect.getOwnPropertyDescriptor(target, P);
|
||||
},
|
||||
|
||||
set(target, P, V, receiver) {
|
||||
if (typeof P === "symbol") {
|
||||
return Reflect.set(target, P, V, receiver);
|
||||
}
|
||||
if (target === receiver) {
|
||||
if (typeof P === "string" && !utils.isArrayIndexPropName(P)) {
|
||||
let namedValue = V;
|
||||
|
||||
namedValue = conversions["DOMString"](namedValue, {
|
||||
context: "Failed to set the '" + P + "' property on 'DOMStringMap': The provided value"
|
||||
});
|
||||
|
||||
const creating = !(target[impl][utils.namedGet](P) !== undefined);
|
||||
if (creating) {
|
||||
target[impl][utils.namedSetNew](P, namedValue);
|
||||
} else {
|
||||
target[impl][utils.namedSetExisting](P, namedValue);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
let ownDesc;
|
||||
|
||||
if (ownDesc === undefined) {
|
||||
ownDesc = Reflect.getOwnPropertyDescriptor(target, P);
|
||||
}
|
||||
if (ownDesc === undefined) {
|
||||
const parent = Reflect.getPrototypeOf(target);
|
||||
if (parent !== null) {
|
||||
return Reflect.set(parent, P, V, receiver);
|
||||
}
|
||||
ownDesc = { writable: true, enumerable: true, configurable: true, value: undefined };
|
||||
}
|
||||
if (!ownDesc.writable) {
|
||||
return false;
|
||||
}
|
||||
if (!utils.isObject(receiver)) {
|
||||
return false;
|
||||
}
|
||||
const existingDesc = Reflect.getOwnPropertyDescriptor(receiver, P);
|
||||
let valueDesc;
|
||||
if (existingDesc !== undefined) {
|
||||
if (existingDesc.get || existingDesc.set) {
|
||||
return false;
|
||||
}
|
||||
if (!existingDesc.writable) {
|
||||
return false;
|
||||
}
|
||||
valueDesc = { value: V };
|
||||
} else {
|
||||
valueDesc = { writable: true, enumerable: true, configurable: true, value: V };
|
||||
}
|
||||
return Reflect.defineProperty(receiver, P, valueDesc);
|
||||
},
|
||||
|
||||
defineProperty(target, P, desc) {
|
||||
if (typeof P === "symbol") {
|
||||
return Reflect.defineProperty(target, P, desc);
|
||||
}
|
||||
|
||||
if (desc.get || desc.set) {
|
||||
return false;
|
||||
}
|
||||
|
||||
let namedValue = desc.value;
|
||||
if (typeof P === "string" && !utils.isArrayIndexPropName(P)) {
|
||||
let namedValue = V;
|
||||
|
||||
namedValue = conversions["DOMString"](namedValue, {
|
||||
context: "Failed to set the '" + P + "' property on 'DOMStringMap': The provided value"
|
||||
});
|
||||
|
||||
const creating = !(target[impl][utils.namedGet](P) !== undefined);
|
||||
if (creating) {
|
||||
target[impl][utils.namedSetNew](P, namedValue);
|
||||
} else {
|
||||
target[impl][utils.namedSetExisting](P, namedValue);
|
||||
ceReactionsPreSteps_helpers_custom_elements(globalObject);
|
||||
try {
|
||||
const creating = !(target[implSymbol][utils.namedGet](P) !== undefined);
|
||||
if (creating) {
|
||||
target[implSymbol][utils.namedSetNew](P, namedValue);
|
||||
} else {
|
||||
target[implSymbol][utils.namedSetExisting](P, namedValue);
|
||||
}
|
||||
} finally {
|
||||
ceReactionsPostSteps_helpers_custom_elements(globalObject);
|
||||
}
|
||||
|
||||
return true;
|
||||
},
|
||||
}
|
||||
}
|
||||
let ownDesc;
|
||||
|
||||
deleteProperty(target, P) {
|
||||
if (typeof P === "symbol") {
|
||||
return Reflect.deleteProperty(target, P);
|
||||
}
|
||||
|
||||
if (target[impl][utils.namedGet](P) !== undefined && !utils.hasOwn(target, P)) {
|
||||
target[impl][utils.namedDelete](P);
|
||||
return true;
|
||||
}
|
||||
|
||||
return Reflect.deleteProperty(target, P);
|
||||
},
|
||||
|
||||
preventExtensions() {
|
||||
if (ownDesc === undefined) {
|
||||
ownDesc = Reflect.getOwnPropertyDescriptor(target, P);
|
||||
}
|
||||
if (ownDesc === undefined) {
|
||||
const parent = Reflect.getPrototypeOf(target);
|
||||
if (parent !== null) {
|
||||
return Reflect.set(parent, P, V, receiver);
|
||||
}
|
||||
ownDesc = { writable: true, enumerable: true, configurable: true, value: undefined };
|
||||
}
|
||||
if (!ownDesc.writable) {
|
||||
return false;
|
||||
}
|
||||
if (!utils.isObject(receiver)) {
|
||||
return false;
|
||||
}
|
||||
const existingDesc = Reflect.getOwnPropertyDescriptor(receiver, P);
|
||||
let valueDesc;
|
||||
if (existingDesc !== undefined) {
|
||||
if (existingDesc.get || existingDesc.set) {
|
||||
return false;
|
||||
}
|
||||
if (!existingDesc.writable) {
|
||||
return false;
|
||||
}
|
||||
valueDesc = { value: V };
|
||||
} else {
|
||||
valueDesc = { writable: true, enumerable: true, configurable: true, value: V };
|
||||
}
|
||||
return Reflect.defineProperty(receiver, P, valueDesc);
|
||||
}
|
||||
|
||||
defineProperty(target, P, desc) {
|
||||
if (typeof P === "symbol") {
|
||||
return Reflect.defineProperty(target, P, desc);
|
||||
}
|
||||
|
||||
const globalObject = this._globalObject;
|
||||
|
||||
if (desc.get || desc.set) {
|
||||
return false;
|
||||
}
|
||||
|
||||
let namedValue = desc.value;
|
||||
|
||||
namedValue = conversions["DOMString"](namedValue, {
|
||||
context: "Failed to set the '" + P + "' property on 'DOMStringMap': The provided value"
|
||||
});
|
||||
|
||||
obj[impl][utils.wrapperSymbol] = obj;
|
||||
if (Impl.init) {
|
||||
Impl.init(obj[impl], privateData);
|
||||
ceReactionsPreSteps_helpers_custom_elements(globalObject);
|
||||
try {
|
||||
const creating = !(target[implSymbol][utils.namedGet](P) !== undefined);
|
||||
if (creating) {
|
||||
target[implSymbol][utils.namedSetNew](P, namedValue);
|
||||
} else {
|
||||
target[implSymbol][utils.namedSetExisting](P, namedValue);
|
||||
}
|
||||
} finally {
|
||||
ceReactionsPostSteps_helpers_custom_elements(globalObject);
|
||||
}
|
||||
return obj;
|
||||
},
|
||||
interface: DOMStringMap,
|
||||
expose: {
|
||||
Window: { DOMStringMap }
|
||||
|
||||
return true;
|
||||
}
|
||||
}; // iface
|
||||
module.exports = iface;
|
||||
|
||||
deleteProperty(target, P) {
|
||||
if (typeof P === "symbol") {
|
||||
return Reflect.deleteProperty(target, P);
|
||||
}
|
||||
|
||||
const globalObject = this._globalObject;
|
||||
|
||||
if (target[implSymbol][utils.namedGet](P) !== undefined && !utils.hasOwn(target, P)) {
|
||||
ceReactionsPreSteps_helpers_custom_elements(globalObject);
|
||||
try {
|
||||
target[implSymbol][utils.namedDelete](P);
|
||||
return true;
|
||||
} finally {
|
||||
ceReactionsPostSteps_helpers_custom_elements(globalObject);
|
||||
}
|
||||
}
|
||||
|
||||
return Reflect.deleteProperty(target, P);
|
||||
}
|
||||
|
||||
preventExtensions() {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
const Impl = require("../nodes/DOMStringMap-impl.js");
|
||||
|
||||
924
node_modules/jsdom/lib/jsdom/living/generated/DOMTokenList.js
generated
vendored
924
node_modules/jsdom/lib/jsdom/living/generated/DOMTokenList.js
generated
vendored
@@ -3,462 +3,528 @@
|
||||
const conversions = require("webidl-conversions");
|
||||
const utils = require("./utils.js");
|
||||
|
||||
const impl = utils.implSymbol;
|
||||
const ceReactionsPreSteps_helpers_custom_elements = require("../helpers/custom-elements.js").ceReactionsPreSteps;
|
||||
const ceReactionsPostSteps_helpers_custom_elements = require("../helpers/custom-elements.js").ceReactionsPostSteps;
|
||||
const implSymbol = utils.implSymbol;
|
||||
const ctorRegistrySymbol = utils.ctorRegistrySymbol;
|
||||
|
||||
function DOMTokenList() {
|
||||
throw new TypeError("Illegal constructor");
|
||||
const interfaceName = "DOMTokenList";
|
||||
|
||||
exports.is = value => {
|
||||
return utils.isObject(value) && utils.hasOwn(value, implSymbol) && value[implSymbol] instanceof Impl.implementation;
|
||||
};
|
||||
exports.isImpl = value => {
|
||||
return utils.isObject(value) && value instanceof Impl.implementation;
|
||||
};
|
||||
exports.convert = (value, { context = "The provided value" } = {}) => {
|
||||
if (exports.is(value)) {
|
||||
return utils.implForWrapper(value);
|
||||
}
|
||||
throw new TypeError(`${context} is not of type 'DOMTokenList'.`);
|
||||
};
|
||||
|
||||
function makeWrapper(globalObject) {
|
||||
if (globalObject[ctorRegistrySymbol] === undefined) {
|
||||
throw new Error("Internal error: invalid global object");
|
||||
}
|
||||
|
||||
const ctor = globalObject[ctorRegistrySymbol]["DOMTokenList"];
|
||||
if (ctor === undefined) {
|
||||
throw new Error("Internal error: constructor DOMTokenList is not installed on the passed global object");
|
||||
}
|
||||
|
||||
return Object.create(ctor.prototype);
|
||||
}
|
||||
|
||||
Object.defineProperty(DOMTokenList, "prototype", {
|
||||
value: DOMTokenList.prototype,
|
||||
writable: false,
|
||||
enumerable: false,
|
||||
configurable: false
|
||||
});
|
||||
|
||||
Object.defineProperty(DOMTokenList.prototype, Symbol.iterator, {
|
||||
writable: true,
|
||||
enumerable: false,
|
||||
configurable: true,
|
||||
value: Array.prototype[Symbol.iterator]
|
||||
});
|
||||
DOMTokenList.prototype.forEach = Array.prototype.forEach;
|
||||
DOMTokenList.prototype.item = function item(index) {
|
||||
if (!this || !module.exports.is(this)) {
|
||||
throw new TypeError("Illegal invocation");
|
||||
}
|
||||
|
||||
if (arguments.length < 1) {
|
||||
throw new TypeError(
|
||||
"Failed to execute 'item' on 'DOMTokenList': 1 argument required, but only " + arguments.length + " present."
|
||||
);
|
||||
}
|
||||
const args = [];
|
||||
{
|
||||
let curArg = arguments[0];
|
||||
curArg = conversions["unsigned long"](curArg, {
|
||||
context: "Failed to execute 'item' on 'DOMTokenList': parameter 1"
|
||||
});
|
||||
args.push(curArg);
|
||||
}
|
||||
return this[impl].item(...args);
|
||||
exports.create = (globalObject, constructorArgs, privateData) => {
|
||||
const wrapper = makeWrapper(globalObject);
|
||||
return exports.setup(wrapper, globalObject, constructorArgs, privateData);
|
||||
};
|
||||
|
||||
DOMTokenList.prototype.contains = function contains(token) {
|
||||
if (!this || !module.exports.is(this)) {
|
||||
throw new TypeError("Illegal invocation");
|
||||
}
|
||||
|
||||
if (arguments.length < 1) {
|
||||
throw new TypeError(
|
||||
"Failed to execute 'contains' on 'DOMTokenList': 1 argument required, but only " + arguments.length + " present."
|
||||
);
|
||||
}
|
||||
const args = [];
|
||||
{
|
||||
let curArg = arguments[0];
|
||||
curArg = conversions["DOMString"](curArg, {
|
||||
context: "Failed to execute 'contains' on 'DOMTokenList': parameter 1"
|
||||
});
|
||||
args.push(curArg);
|
||||
}
|
||||
return this[impl].contains(...args);
|
||||
exports.createImpl = (globalObject, constructorArgs, privateData) => {
|
||||
const wrapper = exports.create(globalObject, constructorArgs, privateData);
|
||||
return utils.implForWrapper(wrapper);
|
||||
};
|
||||
|
||||
DOMTokenList.prototype.add = function add() {
|
||||
if (!this || !module.exports.is(this)) {
|
||||
throw new TypeError("Illegal invocation");
|
||||
exports._internalSetup = (wrapper, globalObject) => {};
|
||||
|
||||
exports.setup = (wrapper, globalObject, constructorArgs = [], privateData = {}) => {
|
||||
privateData.wrapper = wrapper;
|
||||
|
||||
exports._internalSetup(wrapper, globalObject);
|
||||
Object.defineProperty(wrapper, implSymbol, {
|
||||
value: new Impl.implementation(globalObject, constructorArgs, privateData),
|
||||
configurable: true
|
||||
});
|
||||
|
||||
wrapper = new Proxy(wrapper, proxyHandler);
|
||||
|
||||
wrapper[implSymbol][utils.wrapperSymbol] = wrapper;
|
||||
if (Impl.init) {
|
||||
Impl.init(wrapper[implSymbol]);
|
||||
}
|
||||
const args = [];
|
||||
for (let i = 0; i < arguments.length; i++) {
|
||||
let curArg = arguments[i];
|
||||
curArg = conversions["DOMString"](curArg, {
|
||||
context: "Failed to execute 'add' on 'DOMTokenList': parameter " + (i + 1)
|
||||
});
|
||||
args.push(curArg);
|
||||
}
|
||||
return this[impl].add(...args);
|
||||
return wrapper;
|
||||
};
|
||||
|
||||
DOMTokenList.prototype.remove = function remove() {
|
||||
if (!this || !module.exports.is(this)) {
|
||||
throw new TypeError("Illegal invocation");
|
||||
exports.new = globalObject => {
|
||||
let wrapper = makeWrapper(globalObject);
|
||||
|
||||
exports._internalSetup(wrapper, globalObject);
|
||||
Object.defineProperty(wrapper, implSymbol, {
|
||||
value: Object.create(Impl.implementation.prototype),
|
||||
configurable: true
|
||||
});
|
||||
|
||||
wrapper = new Proxy(wrapper, proxyHandler);
|
||||
|
||||
wrapper[implSymbol][utils.wrapperSymbol] = wrapper;
|
||||
if (Impl.init) {
|
||||
Impl.init(wrapper[implSymbol]);
|
||||
}
|
||||
const args = [];
|
||||
for (let i = 0; i < arguments.length; i++) {
|
||||
let curArg = arguments[i];
|
||||
curArg = conversions["DOMString"](curArg, {
|
||||
context: "Failed to execute 'remove' on 'DOMTokenList': parameter " + (i + 1)
|
||||
});
|
||||
args.push(curArg);
|
||||
}
|
||||
return this[impl].remove(...args);
|
||||
return wrapper[implSymbol];
|
||||
};
|
||||
|
||||
DOMTokenList.prototype.toggle = function toggle(token) {
|
||||
if (!this || !module.exports.is(this)) {
|
||||
throw new TypeError("Illegal invocation");
|
||||
}
|
||||
const exposed = new Set(["Window"]);
|
||||
|
||||
if (arguments.length < 1) {
|
||||
throw new TypeError(
|
||||
"Failed to execute 'toggle' on 'DOMTokenList': 1 argument required, but only " + arguments.length + " present."
|
||||
);
|
||||
exports.install = (globalObject, globalNames) => {
|
||||
if (!globalNames.some(globalName => exposed.has(globalName))) {
|
||||
return;
|
||||
}
|
||||
const args = [];
|
||||
{
|
||||
let curArg = arguments[0];
|
||||
curArg = conversions["DOMString"](curArg, { context: "Failed to execute 'toggle' on 'DOMTokenList': parameter 1" });
|
||||
args.push(curArg);
|
||||
}
|
||||
{
|
||||
let curArg = arguments[1];
|
||||
if (curArg !== undefined) {
|
||||
curArg = conversions["boolean"](curArg, { context: "Failed to execute 'toggle' on 'DOMTokenList': parameter 2" });
|
||||
}
|
||||
args.push(curArg);
|
||||
}
|
||||
return this[impl].toggle(...args);
|
||||
};
|
||||
|
||||
DOMTokenList.prototype.replace = function replace(token, newToken) {
|
||||
if (!this || !module.exports.is(this)) {
|
||||
throw new TypeError("Illegal invocation");
|
||||
}
|
||||
|
||||
if (arguments.length < 2) {
|
||||
throw new TypeError(
|
||||
"Failed to execute 'replace' on 'DOMTokenList': 2 arguments required, but only " + arguments.length + " present."
|
||||
);
|
||||
}
|
||||
const args = [];
|
||||
{
|
||||
let curArg = arguments[0];
|
||||
curArg = conversions["DOMString"](curArg, {
|
||||
context: "Failed to execute 'replace' on 'DOMTokenList': parameter 1"
|
||||
});
|
||||
args.push(curArg);
|
||||
}
|
||||
{
|
||||
let curArg = arguments[1];
|
||||
curArg = conversions["DOMString"](curArg, {
|
||||
context: "Failed to execute 'replace' on 'DOMTokenList': parameter 2"
|
||||
});
|
||||
args.push(curArg);
|
||||
}
|
||||
return this[impl].replace(...args);
|
||||
};
|
||||
|
||||
DOMTokenList.prototype.supports = function supports(token) {
|
||||
if (!this || !module.exports.is(this)) {
|
||||
throw new TypeError("Illegal invocation");
|
||||
}
|
||||
|
||||
if (arguments.length < 1) {
|
||||
throw new TypeError(
|
||||
"Failed to execute 'supports' on 'DOMTokenList': 1 argument required, but only " + arguments.length + " present."
|
||||
);
|
||||
}
|
||||
const args = [];
|
||||
{
|
||||
let curArg = arguments[0];
|
||||
curArg = conversions["DOMString"](curArg, {
|
||||
context: "Failed to execute 'supports' on 'DOMTokenList': parameter 1"
|
||||
});
|
||||
args.push(curArg);
|
||||
}
|
||||
return this[impl].supports(...args);
|
||||
};
|
||||
|
||||
DOMTokenList.prototype.entries = Array.prototype.entries;
|
||||
DOMTokenList.prototype.keys = Array.prototype.keys;
|
||||
DOMTokenList.prototype.values = Array.prototype[Symbol.iterator];
|
||||
|
||||
Object.defineProperty(DOMTokenList.prototype, "length", {
|
||||
get() {
|
||||
if (!this || !module.exports.is(this)) {
|
||||
throw new TypeError("Illegal invocation");
|
||||
class DOMTokenList {
|
||||
constructor() {
|
||||
throw new TypeError("Illegal constructor");
|
||||
}
|
||||
|
||||
return this[impl]["length"];
|
||||
},
|
||||
|
||||
enumerable: true,
|
||||
configurable: true
|
||||
});
|
||||
|
||||
Object.defineProperty(DOMTokenList.prototype, "value", {
|
||||
get() {
|
||||
if (!this || !module.exports.is(this)) {
|
||||
throw new TypeError("Illegal invocation");
|
||||
}
|
||||
|
||||
return this[impl]["value"];
|
||||
},
|
||||
|
||||
set(V) {
|
||||
if (!this || !module.exports.is(this)) {
|
||||
throw new TypeError("Illegal invocation");
|
||||
}
|
||||
|
||||
V = conversions["DOMString"](V, {
|
||||
context: "Failed to set the 'value' property on 'DOMTokenList': The provided value"
|
||||
});
|
||||
|
||||
this[impl]["value"] = V;
|
||||
},
|
||||
|
||||
enumerable: true,
|
||||
configurable: true
|
||||
});
|
||||
|
||||
DOMTokenList.prototype.toString = function toString() {
|
||||
if (!this || !module.exports.is(this)) {
|
||||
throw new TypeError("Illegal invocation");
|
||||
}
|
||||
return this[impl]["value"];
|
||||
};
|
||||
|
||||
Object.defineProperty(DOMTokenList.prototype, Symbol.toStringTag, {
|
||||
value: "DOMTokenList",
|
||||
writable: false,
|
||||
enumerable: false,
|
||||
configurable: true
|
||||
});
|
||||
|
||||
const iface = {
|
||||
// When an interface-module that implements this interface as a mixin is loaded, it will append its own `.is()`
|
||||
// method into this array. It allows objects that directly implements *those* interfaces to be recognized as
|
||||
// implementing this mixin interface.
|
||||
_mixedIntoPredicates: [],
|
||||
is(obj) {
|
||||
if (obj) {
|
||||
if (utils.hasOwn(obj, impl) && obj[impl] instanceof Impl.implementation) {
|
||||
return true;
|
||||
item(index) {
|
||||
const esValue = this !== null && this !== undefined ? this : globalObject;
|
||||
if (!exports.is(esValue)) {
|
||||
throw new TypeError("Illegal invocation");
|
||||
}
|
||||
for (const isMixedInto of module.exports._mixedIntoPredicates) {
|
||||
if (isMixedInto(obj)) {
|
||||
return true;
|
||||
|
||||
if (arguments.length < 1) {
|
||||
throw new TypeError(
|
||||
"Failed to execute 'item' on 'DOMTokenList': 1 argument required, but only " + arguments.length + " present."
|
||||
);
|
||||
}
|
||||
const args = [];
|
||||
{
|
||||
let curArg = arguments[0];
|
||||
curArg = conversions["unsigned long"](curArg, {
|
||||
context: "Failed to execute 'item' on 'DOMTokenList': parameter 1"
|
||||
});
|
||||
args.push(curArg);
|
||||
}
|
||||
return esValue[implSymbol].item(...args);
|
||||
}
|
||||
|
||||
contains(token) {
|
||||
const esValue = this !== null && this !== undefined ? this : globalObject;
|
||||
if (!exports.is(esValue)) {
|
||||
throw new TypeError("Illegal invocation");
|
||||
}
|
||||
|
||||
if (arguments.length < 1) {
|
||||
throw new TypeError(
|
||||
"Failed to execute 'contains' on 'DOMTokenList': 1 argument required, but only " +
|
||||
arguments.length +
|
||||
" present."
|
||||
);
|
||||
}
|
||||
const args = [];
|
||||
{
|
||||
let curArg = arguments[0];
|
||||
curArg = conversions["DOMString"](curArg, {
|
||||
context: "Failed to execute 'contains' on 'DOMTokenList': parameter 1"
|
||||
});
|
||||
args.push(curArg);
|
||||
}
|
||||
return esValue[implSymbol].contains(...args);
|
||||
}
|
||||
|
||||
add() {
|
||||
const esValue = this !== null && this !== undefined ? this : globalObject;
|
||||
if (!exports.is(esValue)) {
|
||||
throw new TypeError("Illegal invocation");
|
||||
}
|
||||
const args = [];
|
||||
for (let i = 0; i < arguments.length; i++) {
|
||||
let curArg = arguments[i];
|
||||
curArg = conversions["DOMString"](curArg, {
|
||||
context: "Failed to execute 'add' on 'DOMTokenList': parameter " + (i + 1)
|
||||
});
|
||||
args.push(curArg);
|
||||
}
|
||||
ceReactionsPreSteps_helpers_custom_elements(globalObject);
|
||||
try {
|
||||
return esValue[implSymbol].add(...args);
|
||||
} finally {
|
||||
ceReactionsPostSteps_helpers_custom_elements(globalObject);
|
||||
}
|
||||
}
|
||||
|
||||
remove() {
|
||||
const esValue = this !== null && this !== undefined ? this : globalObject;
|
||||
if (!exports.is(esValue)) {
|
||||
throw new TypeError("Illegal invocation");
|
||||
}
|
||||
const args = [];
|
||||
for (let i = 0; i < arguments.length; i++) {
|
||||
let curArg = arguments[i];
|
||||
curArg = conversions["DOMString"](curArg, {
|
||||
context: "Failed to execute 'remove' on 'DOMTokenList': parameter " + (i + 1)
|
||||
});
|
||||
args.push(curArg);
|
||||
}
|
||||
ceReactionsPreSteps_helpers_custom_elements(globalObject);
|
||||
try {
|
||||
return esValue[implSymbol].remove(...args);
|
||||
} finally {
|
||||
ceReactionsPostSteps_helpers_custom_elements(globalObject);
|
||||
}
|
||||
}
|
||||
|
||||
toggle(token) {
|
||||
const esValue = this !== null && this !== undefined ? this : globalObject;
|
||||
if (!exports.is(esValue)) {
|
||||
throw new TypeError("Illegal invocation");
|
||||
}
|
||||
|
||||
if (arguments.length < 1) {
|
||||
throw new TypeError(
|
||||
"Failed to execute 'toggle' on 'DOMTokenList': 1 argument required, but only " +
|
||||
arguments.length +
|
||||
" present."
|
||||
);
|
||||
}
|
||||
const args = [];
|
||||
{
|
||||
let curArg = arguments[0];
|
||||
curArg = conversions["DOMString"](curArg, {
|
||||
context: "Failed to execute 'toggle' on 'DOMTokenList': parameter 1"
|
||||
});
|
||||
args.push(curArg);
|
||||
}
|
||||
{
|
||||
let curArg = arguments[1];
|
||||
if (curArg !== undefined) {
|
||||
curArg = conversions["boolean"](curArg, {
|
||||
context: "Failed to execute 'toggle' on 'DOMTokenList': parameter 2"
|
||||
});
|
||||
}
|
||||
args.push(curArg);
|
||||
}
|
||||
ceReactionsPreSteps_helpers_custom_elements(globalObject);
|
||||
try {
|
||||
return esValue[implSymbol].toggle(...args);
|
||||
} finally {
|
||||
ceReactionsPostSteps_helpers_custom_elements(globalObject);
|
||||
}
|
||||
}
|
||||
|
||||
replace(token, newToken) {
|
||||
const esValue = this !== null && this !== undefined ? this : globalObject;
|
||||
if (!exports.is(esValue)) {
|
||||
throw new TypeError("Illegal invocation");
|
||||
}
|
||||
|
||||
if (arguments.length < 2) {
|
||||
throw new TypeError(
|
||||
"Failed to execute 'replace' on 'DOMTokenList': 2 arguments required, but only " +
|
||||
arguments.length +
|
||||
" present."
|
||||
);
|
||||
}
|
||||
const args = [];
|
||||
{
|
||||
let curArg = arguments[0];
|
||||
curArg = conversions["DOMString"](curArg, {
|
||||
context: "Failed to execute 'replace' on 'DOMTokenList': parameter 1"
|
||||
});
|
||||
args.push(curArg);
|
||||
}
|
||||
{
|
||||
let curArg = arguments[1];
|
||||
curArg = conversions["DOMString"](curArg, {
|
||||
context: "Failed to execute 'replace' on 'DOMTokenList': parameter 2"
|
||||
});
|
||||
args.push(curArg);
|
||||
}
|
||||
ceReactionsPreSteps_helpers_custom_elements(globalObject);
|
||||
try {
|
||||
return esValue[implSymbol].replace(...args);
|
||||
} finally {
|
||||
ceReactionsPostSteps_helpers_custom_elements(globalObject);
|
||||
}
|
||||
}
|
||||
|
||||
supports(token) {
|
||||
const esValue = this !== null && this !== undefined ? this : globalObject;
|
||||
if (!exports.is(esValue)) {
|
||||
throw new TypeError("Illegal invocation");
|
||||
}
|
||||
|
||||
if (arguments.length < 1) {
|
||||
throw new TypeError(
|
||||
"Failed to execute 'supports' on 'DOMTokenList': 1 argument required, but only " +
|
||||
arguments.length +
|
||||
" present."
|
||||
);
|
||||
}
|
||||
const args = [];
|
||||
{
|
||||
let curArg = arguments[0];
|
||||
curArg = conversions["DOMString"](curArg, {
|
||||
context: "Failed to execute 'supports' on 'DOMTokenList': parameter 1"
|
||||
});
|
||||
args.push(curArg);
|
||||
}
|
||||
return esValue[implSymbol].supports(...args);
|
||||
}
|
||||
|
||||
get length() {
|
||||
const esValue = this !== null && this !== undefined ? this : globalObject;
|
||||
|
||||
if (!exports.is(esValue)) {
|
||||
throw new TypeError("Illegal invocation");
|
||||
}
|
||||
|
||||
return esValue[implSymbol]["length"];
|
||||
}
|
||||
|
||||
get value() {
|
||||
const esValue = this !== null && this !== undefined ? this : globalObject;
|
||||
|
||||
if (!exports.is(esValue)) {
|
||||
throw new TypeError("Illegal invocation");
|
||||
}
|
||||
|
||||
ceReactionsPreSteps_helpers_custom_elements(globalObject);
|
||||
try {
|
||||
return esValue[implSymbol]["value"];
|
||||
} finally {
|
||||
ceReactionsPostSteps_helpers_custom_elements(globalObject);
|
||||
}
|
||||
}
|
||||
|
||||
set value(V) {
|
||||
const esValue = this !== null && this !== undefined ? this : globalObject;
|
||||
|
||||
if (!exports.is(esValue)) {
|
||||
throw new TypeError("Illegal invocation");
|
||||
}
|
||||
|
||||
V = conversions["DOMString"](V, {
|
||||
context: "Failed to set the 'value' property on 'DOMTokenList': The provided value"
|
||||
});
|
||||
|
||||
ceReactionsPreSteps_helpers_custom_elements(globalObject);
|
||||
try {
|
||||
esValue[implSymbol]["value"] = V;
|
||||
} finally {
|
||||
ceReactionsPostSteps_helpers_custom_elements(globalObject);
|
||||
}
|
||||
}
|
||||
|
||||
toString() {
|
||||
const esValue = this;
|
||||
if (!exports.is(esValue)) {
|
||||
throw new TypeError("Illegal invocation");
|
||||
}
|
||||
|
||||
ceReactionsPreSteps_helpers_custom_elements(globalObject);
|
||||
try {
|
||||
return esValue[implSymbol]["value"];
|
||||
} finally {
|
||||
ceReactionsPostSteps_helpers_custom_elements(globalObject);
|
||||
}
|
||||
}
|
||||
}
|
||||
Object.defineProperties(DOMTokenList.prototype, {
|
||||
item: { enumerable: true },
|
||||
contains: { enumerable: true },
|
||||
add: { enumerable: true },
|
||||
remove: { enumerable: true },
|
||||
toggle: { enumerable: true },
|
||||
replace: { enumerable: true },
|
||||
supports: { enumerable: true },
|
||||
length: { enumerable: true },
|
||||
value: { enumerable: true },
|
||||
toString: { enumerable: true },
|
||||
[Symbol.toStringTag]: { value: "DOMTokenList", configurable: true },
|
||||
[Symbol.iterator]: { value: Array.prototype[Symbol.iterator], configurable: true, writable: true },
|
||||
keys: { value: Array.prototype.keys, configurable: true, enumerable: true, writable: true },
|
||||
values: { value: Array.prototype[Symbol.iterator], configurable: true, enumerable: true, writable: true },
|
||||
entries: { value: Array.prototype.entries, configurable: true, enumerable: true, writable: true },
|
||||
forEach: { value: Array.prototype.forEach, configurable: true, enumerable: true, writable: true }
|
||||
});
|
||||
if (globalObject[ctorRegistrySymbol] === undefined) {
|
||||
globalObject[ctorRegistrySymbol] = Object.create(null);
|
||||
}
|
||||
globalObject[ctorRegistrySymbol][interfaceName] = DOMTokenList;
|
||||
|
||||
Object.defineProperty(globalObject, interfaceName, {
|
||||
configurable: true,
|
||||
writable: true,
|
||||
value: DOMTokenList
|
||||
});
|
||||
};
|
||||
|
||||
const proxyHandler = {
|
||||
get(target, P, receiver) {
|
||||
if (typeof P === "symbol") {
|
||||
return Reflect.get(target, P, receiver);
|
||||
}
|
||||
const desc = this.getOwnPropertyDescriptor(target, P);
|
||||
if (desc === undefined) {
|
||||
const parent = Object.getPrototypeOf(target);
|
||||
if (parent === null) {
|
||||
return undefined;
|
||||
}
|
||||
return Reflect.get(target, P, receiver);
|
||||
}
|
||||
if (!desc.get && !desc.set) {
|
||||
return desc.value;
|
||||
}
|
||||
const getter = desc.get;
|
||||
if (getter === undefined) {
|
||||
return undefined;
|
||||
}
|
||||
return Reflect.apply(getter, receiver, []);
|
||||
},
|
||||
|
||||
has(target, P) {
|
||||
if (typeof P === "symbol") {
|
||||
return Reflect.has(target, P);
|
||||
}
|
||||
const desc = this.getOwnPropertyDescriptor(target, P);
|
||||
if (desc !== undefined) {
|
||||
return true;
|
||||
}
|
||||
const parent = Object.getPrototypeOf(target);
|
||||
if (parent !== null) {
|
||||
return Reflect.has(parent, P);
|
||||
}
|
||||
return false;
|
||||
},
|
||||
isImpl(obj) {
|
||||
if (obj) {
|
||||
if (obj instanceof Impl.implementation) {
|
||||
return true;
|
||||
}
|
||||
|
||||
const wrapper = utils.wrapperForImpl(obj);
|
||||
for (const isMixedInto of module.exports._mixedIntoPredicates) {
|
||||
if (isMixedInto(wrapper)) {
|
||||
return true;
|
||||
}
|
||||
ownKeys(target) {
|
||||
const keys = new Set();
|
||||
|
||||
for (const key of target[implSymbol][utils.supportedPropertyIndices]) {
|
||||
keys.add(`${key}`);
|
||||
}
|
||||
|
||||
for (const key of Reflect.ownKeys(target)) {
|
||||
keys.add(key);
|
||||
}
|
||||
return [...keys];
|
||||
},
|
||||
|
||||
getOwnPropertyDescriptor(target, P) {
|
||||
if (typeof P === "symbol") {
|
||||
return Reflect.getOwnPropertyDescriptor(target, P);
|
||||
}
|
||||
let ignoreNamedProps = false;
|
||||
|
||||
if (utils.isArrayIndexPropName(P)) {
|
||||
const index = P >>> 0;
|
||||
const indexedValue = target[implSymbol].item(index);
|
||||
if (indexedValue !== null) {
|
||||
return {
|
||||
writable: false,
|
||||
enumerable: true,
|
||||
configurable: true,
|
||||
value: utils.tryWrapperForImpl(indexedValue)
|
||||
};
|
||||
}
|
||||
ignoreNamedProps = true;
|
||||
}
|
||||
|
||||
return Reflect.getOwnPropertyDescriptor(target, P);
|
||||
},
|
||||
|
||||
set(target, P, V, receiver) {
|
||||
if (typeof P === "symbol") {
|
||||
return Reflect.set(target, P, V, receiver);
|
||||
}
|
||||
if (target === receiver) {
|
||||
utils.isArrayIndexPropName(P);
|
||||
}
|
||||
let ownDesc;
|
||||
|
||||
if (utils.isArrayIndexPropName(P)) {
|
||||
const index = P >>> 0;
|
||||
const indexedValue = target[implSymbol].item(index);
|
||||
if (indexedValue !== null) {
|
||||
ownDesc = {
|
||||
writable: false,
|
||||
enumerable: true,
|
||||
configurable: true,
|
||||
value: utils.tryWrapperForImpl(indexedValue)
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
if (ownDesc === undefined) {
|
||||
ownDesc = Reflect.getOwnPropertyDescriptor(target, P);
|
||||
}
|
||||
if (ownDesc === undefined) {
|
||||
const parent = Reflect.getPrototypeOf(target);
|
||||
if (parent !== null) {
|
||||
return Reflect.set(parent, P, V, receiver);
|
||||
}
|
||||
ownDesc = { writable: true, enumerable: true, configurable: true, value: undefined };
|
||||
}
|
||||
if (!ownDesc.writable) {
|
||||
return false;
|
||||
}
|
||||
if (!utils.isObject(receiver)) {
|
||||
return false;
|
||||
}
|
||||
const existingDesc = Reflect.getOwnPropertyDescriptor(receiver, P);
|
||||
let valueDesc;
|
||||
if (existingDesc !== undefined) {
|
||||
if (existingDesc.get || existingDesc.set) {
|
||||
return false;
|
||||
}
|
||||
if (!existingDesc.writable) {
|
||||
return false;
|
||||
}
|
||||
valueDesc = { value: V };
|
||||
} else {
|
||||
valueDesc = { writable: true, enumerable: true, configurable: true, value: V };
|
||||
}
|
||||
return Reflect.defineProperty(receiver, P, valueDesc);
|
||||
},
|
||||
|
||||
defineProperty(target, P, desc) {
|
||||
if (typeof P === "symbol") {
|
||||
return Reflect.defineProperty(target, P, desc);
|
||||
}
|
||||
|
||||
if (utils.isArrayIndexPropName(P)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return Reflect.defineProperty(target, P, desc);
|
||||
},
|
||||
|
||||
deleteProperty(target, P) {
|
||||
if (typeof P === "symbol") {
|
||||
return Reflect.deleteProperty(target, P);
|
||||
}
|
||||
|
||||
if (utils.isArrayIndexPropName(P)) {
|
||||
const index = P >>> 0;
|
||||
return !(target[implSymbol].item(index) !== null);
|
||||
}
|
||||
|
||||
return Reflect.deleteProperty(target, P);
|
||||
},
|
||||
|
||||
preventExtensions() {
|
||||
return false;
|
||||
},
|
||||
convert(obj, { context = "The provided value" } = {}) {
|
||||
if (module.exports.is(obj)) {
|
||||
return utils.implForWrapper(obj);
|
||||
}
|
||||
throw new TypeError(`${context} is not of type 'DOMTokenList'.`);
|
||||
},
|
||||
|
||||
create(constructorArgs, privateData) {
|
||||
let obj = Object.create(DOMTokenList.prototype);
|
||||
obj = this.setup(obj, constructorArgs, privateData);
|
||||
return obj;
|
||||
},
|
||||
createImpl(constructorArgs, privateData) {
|
||||
let obj = Object.create(DOMTokenList.prototype);
|
||||
obj = this.setup(obj, constructorArgs, privateData);
|
||||
return utils.implForWrapper(obj);
|
||||
},
|
||||
_internalSetup(obj) {},
|
||||
setup(obj, constructorArgs, privateData) {
|
||||
if (!privateData) privateData = {};
|
||||
|
||||
privateData.wrapper = obj;
|
||||
|
||||
this._internalSetup(obj);
|
||||
Object.defineProperty(obj, impl, {
|
||||
value: new Impl.implementation(constructorArgs, privateData),
|
||||
writable: false,
|
||||
enumerable: false,
|
||||
configurable: true
|
||||
});
|
||||
|
||||
obj = new Proxy(obj, {
|
||||
get(target, P, receiver) {
|
||||
if (typeof P === "symbol") {
|
||||
return Reflect.get(target, P, receiver);
|
||||
}
|
||||
const desc = this.getOwnPropertyDescriptor(target, P);
|
||||
if (desc === undefined) {
|
||||
const parent = Object.getPrototypeOf(target);
|
||||
if (parent === null) {
|
||||
return undefined;
|
||||
}
|
||||
return Reflect.get(target, P, receiver);
|
||||
}
|
||||
if (!desc.get && !desc.set) {
|
||||
return desc.value;
|
||||
}
|
||||
const getter = desc.get;
|
||||
if (getter === undefined) {
|
||||
return undefined;
|
||||
}
|
||||
return Reflect.apply(getter, receiver, []);
|
||||
},
|
||||
|
||||
has(target, P) {
|
||||
if (typeof P === "symbol") {
|
||||
return Reflect.has(target, P);
|
||||
}
|
||||
const desc = this.getOwnPropertyDescriptor(target, P);
|
||||
if (desc !== undefined) {
|
||||
return true;
|
||||
}
|
||||
const parent = Object.getPrototypeOf(target);
|
||||
if (parent !== null) {
|
||||
return Reflect.has(parent, P);
|
||||
}
|
||||
return false;
|
||||
},
|
||||
|
||||
ownKeys(target) {
|
||||
const keys = new Set();
|
||||
|
||||
for (const key of target[impl][utils.supportedPropertyIndices]) {
|
||||
keys.add(`${key}`);
|
||||
}
|
||||
|
||||
for (const key of Reflect.ownKeys(target)) {
|
||||
keys.add(key);
|
||||
}
|
||||
return [...keys];
|
||||
},
|
||||
|
||||
getOwnPropertyDescriptor(target, P) {
|
||||
if (typeof P === "symbol") {
|
||||
return Reflect.getOwnPropertyDescriptor(target, P);
|
||||
}
|
||||
let ignoreNamedProps = false;
|
||||
|
||||
if (utils.isArrayIndexPropName(P)) {
|
||||
const index = P >>> 0;
|
||||
const indexedValue = target[impl].item(index);
|
||||
if (indexedValue !== null) {
|
||||
return {
|
||||
writable: false,
|
||||
enumerable: true,
|
||||
configurable: true,
|
||||
value: utils.tryWrapperForImpl(indexedValue)
|
||||
};
|
||||
}
|
||||
ignoreNamedProps = true;
|
||||
}
|
||||
|
||||
return Reflect.getOwnPropertyDescriptor(target, P);
|
||||
},
|
||||
|
||||
set(target, P, V, receiver) {
|
||||
if (typeof P === "symbol") {
|
||||
return Reflect.set(target, P, V, receiver);
|
||||
}
|
||||
if (target === receiver) {
|
||||
utils.isArrayIndexPropName(P);
|
||||
}
|
||||
let ownDesc;
|
||||
|
||||
if (utils.isArrayIndexPropName(P)) {
|
||||
const index = P >>> 0;
|
||||
const indexedValue = target[impl].item(index);
|
||||
if (indexedValue !== null) {
|
||||
ownDesc = {
|
||||
writable: false,
|
||||
enumerable: true,
|
||||
configurable: true,
|
||||
value: utils.tryWrapperForImpl(indexedValue)
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
if (ownDesc === undefined) {
|
||||
ownDesc = Reflect.getOwnPropertyDescriptor(target, P);
|
||||
}
|
||||
if (ownDesc === undefined) {
|
||||
const parent = Reflect.getPrototypeOf(target);
|
||||
if (parent !== null) {
|
||||
return Reflect.set(parent, P, V, receiver);
|
||||
}
|
||||
ownDesc = { writable: true, enumerable: true, configurable: true, value: undefined };
|
||||
}
|
||||
if (!ownDesc.writable) {
|
||||
return false;
|
||||
}
|
||||
if (!utils.isObject(receiver)) {
|
||||
return false;
|
||||
}
|
||||
const existingDesc = Reflect.getOwnPropertyDescriptor(receiver, P);
|
||||
let valueDesc;
|
||||
if (existingDesc !== undefined) {
|
||||
if (existingDesc.get || existingDesc.set) {
|
||||
return false;
|
||||
}
|
||||
if (!existingDesc.writable) {
|
||||
return false;
|
||||
}
|
||||
valueDesc = { value: V };
|
||||
} else {
|
||||
valueDesc = { writable: true, enumerable: true, configurable: true, value: V };
|
||||
}
|
||||
return Reflect.defineProperty(receiver, P, valueDesc);
|
||||
},
|
||||
|
||||
defineProperty(target, P, desc) {
|
||||
if (typeof P === "symbol") {
|
||||
return Reflect.defineProperty(target, P, desc);
|
||||
}
|
||||
|
||||
if (utils.isArrayIndexPropName(P)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return Reflect.defineProperty(target, P, desc);
|
||||
},
|
||||
|
||||
deleteProperty(target, P) {
|
||||
if (typeof P === "symbol") {
|
||||
return Reflect.deleteProperty(target, P);
|
||||
}
|
||||
|
||||
if (utils.isArrayIndexPropName(P)) {
|
||||
const index = P >>> 0;
|
||||
return !(target[impl].item(index) !== null);
|
||||
}
|
||||
|
||||
return Reflect.deleteProperty(target, P);
|
||||
},
|
||||
|
||||
preventExtensions() {
|
||||
return false;
|
||||
}
|
||||
});
|
||||
|
||||
obj[impl][utils.wrapperSymbol] = obj;
|
||||
if (Impl.init) {
|
||||
Impl.init(obj[impl], privateData);
|
||||
}
|
||||
return obj;
|
||||
},
|
||||
interface: DOMTokenList,
|
||||
expose: {
|
||||
Window: { DOMTokenList }
|
||||
}
|
||||
}; // iface
|
||||
module.exports = iface;
|
||||
};
|
||||
|
||||
const Impl = require("../nodes/DOMTokenList-impl.js");
|
||||
|
||||
5749
node_modules/jsdom/lib/jsdom/living/generated/Document.js
generated
vendored
5749
node_modules/jsdom/lib/jsdom/living/generated/Document.js
generated
vendored
File diff suppressed because it is too large
Load Diff
520
node_modules/jsdom/lib/jsdom/living/generated/DocumentFragment.js
generated
vendored
520
node_modules/jsdom/lib/jsdom/living/generated/DocumentFragment.js
generated
vendored
@@ -3,282 +3,288 @@
|
||||
const conversions = require("webidl-conversions");
|
||||
const utils = require("./utils.js");
|
||||
|
||||
const isNode = require("./Node.js").is;
|
||||
const impl = utils.implSymbol;
|
||||
const Node = require("./Node.js");
|
||||
const NonElementParentNode = require("./NonElementParentNode.js");
|
||||
const ParentNode = require("./ParentNode.js");
|
||||
const ceReactionsPreSteps_helpers_custom_elements = require("../helpers/custom-elements.js").ceReactionsPreSteps;
|
||||
const ceReactionsPostSteps_helpers_custom_elements = require("../helpers/custom-elements.js").ceReactionsPostSteps;
|
||||
const implSymbol = utils.implSymbol;
|
||||
const ctorRegistrySymbol = utils.ctorRegistrySymbol;
|
||||
|
||||
function DocumentFragment() {
|
||||
if (new.target === undefined) {
|
||||
throw new TypeError(
|
||||
"Failed to construct 'DocumentFragment'. Please use the 'new' operator; this constructor " +
|
||||
"cannot be called as a function."
|
||||
);
|
||||
const interfaceName = "DocumentFragment";
|
||||
|
||||
exports.is = value => {
|
||||
return utils.isObject(value) && utils.hasOwn(value, implSymbol) && value[implSymbol] instanceof Impl.implementation;
|
||||
};
|
||||
exports.isImpl = value => {
|
||||
return utils.isObject(value) && value instanceof Impl.implementation;
|
||||
};
|
||||
exports.convert = (value, { context = "The provided value" } = {}) => {
|
||||
if (exports.is(value)) {
|
||||
return utils.implForWrapper(value);
|
||||
}
|
||||
throw new TypeError(`${context} is not of type 'DocumentFragment'.`);
|
||||
};
|
||||
|
||||
function makeWrapper(globalObject) {
|
||||
if (globalObject[ctorRegistrySymbol] === undefined) {
|
||||
throw new Error("Internal error: invalid global object");
|
||||
}
|
||||
|
||||
iface.setup(this);
|
||||
const ctor = globalObject[ctorRegistrySymbol]["DocumentFragment"];
|
||||
if (ctor === undefined) {
|
||||
throw new Error("Internal error: constructor DocumentFragment is not installed on the passed global object");
|
||||
}
|
||||
|
||||
return Object.create(ctor.prototype);
|
||||
}
|
||||
|
||||
Object.setPrototypeOf(DocumentFragment.prototype, Node.interface.prototype);
|
||||
Object.setPrototypeOf(DocumentFragment, Node.interface);
|
||||
|
||||
Object.defineProperty(DocumentFragment, "prototype", {
|
||||
value: DocumentFragment.prototype,
|
||||
writable: false,
|
||||
enumerable: false,
|
||||
configurable: false
|
||||
});
|
||||
|
||||
DocumentFragment.prototype.getElementById = function getElementById(elementId) {
|
||||
if (!this || !module.exports.is(this)) {
|
||||
throw new TypeError("Illegal invocation");
|
||||
}
|
||||
|
||||
if (arguments.length < 1) {
|
||||
throw new TypeError(
|
||||
"Failed to execute 'getElementById' on 'DocumentFragment': 1 argument required, but only " +
|
||||
arguments.length +
|
||||
" present."
|
||||
);
|
||||
}
|
||||
const args = [];
|
||||
{
|
||||
let curArg = arguments[0];
|
||||
curArg = conversions["DOMString"](curArg, {
|
||||
context: "Failed to execute 'getElementById' on 'DocumentFragment': parameter 1"
|
||||
});
|
||||
args.push(curArg);
|
||||
}
|
||||
return utils.tryWrapperForImpl(this[impl].getElementById(...args));
|
||||
exports.create = (globalObject, constructorArgs, privateData) => {
|
||||
const wrapper = makeWrapper(globalObject);
|
||||
return exports.setup(wrapper, globalObject, constructorArgs, privateData);
|
||||
};
|
||||
|
||||
DocumentFragment.prototype.prepend = function prepend() {
|
||||
if (!this || !module.exports.is(this)) {
|
||||
throw new TypeError("Illegal invocation");
|
||||
exports.createImpl = (globalObject, constructorArgs, privateData) => {
|
||||
const wrapper = exports.create(globalObject, constructorArgs, privateData);
|
||||
return utils.implForWrapper(wrapper);
|
||||
};
|
||||
|
||||
exports._internalSetup = (wrapper, globalObject) => {
|
||||
Node._internalSetup(wrapper, globalObject);
|
||||
};
|
||||
|
||||
exports.setup = (wrapper, globalObject, constructorArgs = [], privateData = {}) => {
|
||||
privateData.wrapper = wrapper;
|
||||
|
||||
exports._internalSetup(wrapper, globalObject);
|
||||
Object.defineProperty(wrapper, implSymbol, {
|
||||
value: new Impl.implementation(globalObject, constructorArgs, privateData),
|
||||
configurable: true
|
||||
});
|
||||
|
||||
wrapper[implSymbol][utils.wrapperSymbol] = wrapper;
|
||||
if (Impl.init) {
|
||||
Impl.init(wrapper[implSymbol]);
|
||||
}
|
||||
const args = [];
|
||||
for (let i = 0; i < arguments.length; i++) {
|
||||
let curArg = arguments[i];
|
||||
if (isNode(curArg)) {
|
||||
curArg = utils.implForWrapper(curArg);
|
||||
} else {
|
||||
curArg = conversions["DOMString"](curArg, {
|
||||
context: "Failed to execute 'prepend' on 'DocumentFragment': parameter " + (i + 1)
|
||||
return wrapper;
|
||||
};
|
||||
|
||||
exports.new = globalObject => {
|
||||
const wrapper = makeWrapper(globalObject);
|
||||
|
||||
exports._internalSetup(wrapper, globalObject);
|
||||
Object.defineProperty(wrapper, implSymbol, {
|
||||
value: Object.create(Impl.implementation.prototype),
|
||||
configurable: true
|
||||
});
|
||||
|
||||
wrapper[implSymbol][utils.wrapperSymbol] = wrapper;
|
||||
if (Impl.init) {
|
||||
Impl.init(wrapper[implSymbol]);
|
||||
}
|
||||
return wrapper[implSymbol];
|
||||
};
|
||||
|
||||
const exposed = new Set(["Window"]);
|
||||
|
||||
exports.install = (globalObject, globalNames) => {
|
||||
if (!globalNames.some(globalName => exposed.has(globalName))) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (globalObject.Node === undefined) {
|
||||
throw new Error("Internal error: attempting to evaluate DocumentFragment before Node");
|
||||
}
|
||||
class DocumentFragment extends globalObject.Node {
|
||||
constructor() {
|
||||
return exports.setup(Object.create(new.target.prototype), globalObject, undefined);
|
||||
}
|
||||
|
||||
getElementById(elementId) {
|
||||
const esValue = this !== null && this !== undefined ? this : globalObject;
|
||||
if (!exports.is(esValue)) {
|
||||
throw new TypeError("Illegal invocation");
|
||||
}
|
||||
|
||||
if (arguments.length < 1) {
|
||||
throw new TypeError(
|
||||
"Failed to execute 'getElementById' on 'DocumentFragment': 1 argument required, but only " +
|
||||
arguments.length +
|
||||
" present."
|
||||
);
|
||||
}
|
||||
const args = [];
|
||||
{
|
||||
let curArg = arguments[0];
|
||||
curArg = conversions["DOMString"](curArg, {
|
||||
context: "Failed to execute 'getElementById' on 'DocumentFragment': parameter 1"
|
||||
});
|
||||
args.push(curArg);
|
||||
}
|
||||
return utils.tryWrapperForImpl(esValue[implSymbol].getElementById(...args));
|
||||
}
|
||||
|
||||
prepend() {
|
||||
const esValue = this !== null && this !== undefined ? this : globalObject;
|
||||
if (!exports.is(esValue)) {
|
||||
throw new TypeError("Illegal invocation");
|
||||
}
|
||||
const args = [];
|
||||
for (let i = 0; i < arguments.length; i++) {
|
||||
let curArg = arguments[i];
|
||||
if (Node.is(curArg)) {
|
||||
curArg = utils.implForWrapper(curArg);
|
||||
} else {
|
||||
curArg = conversions["DOMString"](curArg, {
|
||||
context: "Failed to execute 'prepend' on 'DocumentFragment': parameter " + (i + 1)
|
||||
});
|
||||
}
|
||||
args.push(curArg);
|
||||
}
|
||||
ceReactionsPreSteps_helpers_custom_elements(globalObject);
|
||||
try {
|
||||
return esValue[implSymbol].prepend(...args);
|
||||
} finally {
|
||||
ceReactionsPostSteps_helpers_custom_elements(globalObject);
|
||||
}
|
||||
}
|
||||
|
||||
append() {
|
||||
const esValue = this !== null && this !== undefined ? this : globalObject;
|
||||
if (!exports.is(esValue)) {
|
||||
throw new TypeError("Illegal invocation");
|
||||
}
|
||||
const args = [];
|
||||
for (let i = 0; i < arguments.length; i++) {
|
||||
let curArg = arguments[i];
|
||||
if (Node.is(curArg)) {
|
||||
curArg = utils.implForWrapper(curArg);
|
||||
} else {
|
||||
curArg = conversions["DOMString"](curArg, {
|
||||
context: "Failed to execute 'append' on 'DocumentFragment': parameter " + (i + 1)
|
||||
});
|
||||
}
|
||||
args.push(curArg);
|
||||
}
|
||||
ceReactionsPreSteps_helpers_custom_elements(globalObject);
|
||||
try {
|
||||
return esValue[implSymbol].append(...args);
|
||||
} finally {
|
||||
ceReactionsPostSteps_helpers_custom_elements(globalObject);
|
||||
}
|
||||
}
|
||||
|
||||
querySelector(selectors) {
|
||||
const esValue = this !== null && this !== undefined ? this : globalObject;
|
||||
if (!exports.is(esValue)) {
|
||||
throw new TypeError("Illegal invocation");
|
||||
}
|
||||
|
||||
if (arguments.length < 1) {
|
||||
throw new TypeError(
|
||||
"Failed to execute 'querySelector' on 'DocumentFragment': 1 argument required, but only " +
|
||||
arguments.length +
|
||||
" present."
|
||||
);
|
||||
}
|
||||
const args = [];
|
||||
{
|
||||
let curArg = arguments[0];
|
||||
curArg = conversions["DOMString"](curArg, {
|
||||
context: "Failed to execute 'querySelector' on 'DocumentFragment': parameter 1"
|
||||
});
|
||||
args.push(curArg);
|
||||
}
|
||||
return utils.tryWrapperForImpl(esValue[implSymbol].querySelector(...args));
|
||||
}
|
||||
|
||||
querySelectorAll(selectors) {
|
||||
const esValue = this !== null && this !== undefined ? this : globalObject;
|
||||
if (!exports.is(esValue)) {
|
||||
throw new TypeError("Illegal invocation");
|
||||
}
|
||||
|
||||
if (arguments.length < 1) {
|
||||
throw new TypeError(
|
||||
"Failed to execute 'querySelectorAll' on 'DocumentFragment': 1 argument required, but only " +
|
||||
arguments.length +
|
||||
" present."
|
||||
);
|
||||
}
|
||||
const args = [];
|
||||
{
|
||||
let curArg = arguments[0];
|
||||
curArg = conversions["DOMString"](curArg, {
|
||||
context: "Failed to execute 'querySelectorAll' on 'DocumentFragment': parameter 1"
|
||||
});
|
||||
args.push(curArg);
|
||||
}
|
||||
return utils.tryWrapperForImpl(esValue[implSymbol].querySelectorAll(...args));
|
||||
}
|
||||
|
||||
get children() {
|
||||
const esValue = this !== null && this !== undefined ? this : globalObject;
|
||||
|
||||
if (!exports.is(esValue)) {
|
||||
throw new TypeError("Illegal invocation");
|
||||
}
|
||||
|
||||
return utils.getSameObject(this, "children", () => {
|
||||
return utils.tryWrapperForImpl(esValue[implSymbol]["children"]);
|
||||
});
|
||||
}
|
||||
args.push(curArg);
|
||||
}
|
||||
return this[impl].prepend(...args);
|
||||
};
|
||||
|
||||
DocumentFragment.prototype.append = function append() {
|
||||
if (!this || !module.exports.is(this)) {
|
||||
throw new TypeError("Illegal invocation");
|
||||
}
|
||||
const args = [];
|
||||
for (let i = 0; i < arguments.length; i++) {
|
||||
let curArg = arguments[i];
|
||||
if (isNode(curArg)) {
|
||||
curArg = utils.implForWrapper(curArg);
|
||||
} else {
|
||||
curArg = conversions["DOMString"](curArg, {
|
||||
context: "Failed to execute 'append' on 'DocumentFragment': parameter " + (i + 1)
|
||||
});
|
||||
}
|
||||
args.push(curArg);
|
||||
}
|
||||
return this[impl].append(...args);
|
||||
};
|
||||
get firstElementChild() {
|
||||
const esValue = this !== null && this !== undefined ? this : globalObject;
|
||||
|
||||
DocumentFragment.prototype.querySelector = function querySelector(selectors) {
|
||||
if (!this || !module.exports.is(this)) {
|
||||
throw new TypeError("Illegal invocation");
|
||||
}
|
||||
|
||||
if (arguments.length < 1) {
|
||||
throw new TypeError(
|
||||
"Failed to execute 'querySelector' on 'DocumentFragment': 1 argument required, but only " +
|
||||
arguments.length +
|
||||
" present."
|
||||
);
|
||||
}
|
||||
const args = [];
|
||||
{
|
||||
let curArg = arguments[0];
|
||||
curArg = conversions["DOMString"](curArg, {
|
||||
context: "Failed to execute 'querySelector' on 'DocumentFragment': parameter 1"
|
||||
});
|
||||
args.push(curArg);
|
||||
}
|
||||
return utils.tryWrapperForImpl(this[impl].querySelector(...args));
|
||||
};
|
||||
|
||||
DocumentFragment.prototype.querySelectorAll = function querySelectorAll(selectors) {
|
||||
if (!this || !module.exports.is(this)) {
|
||||
throw new TypeError("Illegal invocation");
|
||||
}
|
||||
|
||||
if (arguments.length < 1) {
|
||||
throw new TypeError(
|
||||
"Failed to execute 'querySelectorAll' on 'DocumentFragment': 1 argument required, but only " +
|
||||
arguments.length +
|
||||
" present."
|
||||
);
|
||||
}
|
||||
const args = [];
|
||||
{
|
||||
let curArg = arguments[0];
|
||||
curArg = conversions["DOMString"](curArg, {
|
||||
context: "Failed to execute 'querySelectorAll' on 'DocumentFragment': parameter 1"
|
||||
});
|
||||
args.push(curArg);
|
||||
}
|
||||
return utils.tryWrapperForImpl(this[impl].querySelectorAll(...args));
|
||||
};
|
||||
|
||||
Object.defineProperty(DocumentFragment.prototype, "children", {
|
||||
get() {
|
||||
if (!this || !module.exports.is(this)) {
|
||||
throw new TypeError("Illegal invocation");
|
||||
}
|
||||
|
||||
return utils.getSameObject(this, "children", () => {
|
||||
return utils.tryWrapperForImpl(this[impl]["children"]);
|
||||
});
|
||||
},
|
||||
|
||||
enumerable: true,
|
||||
configurable: true
|
||||
});
|
||||
|
||||
Object.defineProperty(DocumentFragment.prototype, "firstElementChild", {
|
||||
get() {
|
||||
if (!this || !module.exports.is(this)) {
|
||||
throw new TypeError("Illegal invocation");
|
||||
}
|
||||
|
||||
return utils.tryWrapperForImpl(this[impl]["firstElementChild"]);
|
||||
},
|
||||
|
||||
enumerable: true,
|
||||
configurable: true
|
||||
});
|
||||
|
||||
Object.defineProperty(DocumentFragment.prototype, "lastElementChild", {
|
||||
get() {
|
||||
if (!this || !module.exports.is(this)) {
|
||||
throw new TypeError("Illegal invocation");
|
||||
}
|
||||
|
||||
return utils.tryWrapperForImpl(this[impl]["lastElementChild"]);
|
||||
},
|
||||
|
||||
enumerable: true,
|
||||
configurable: true
|
||||
});
|
||||
|
||||
Object.defineProperty(DocumentFragment.prototype, "childElementCount", {
|
||||
get() {
|
||||
if (!this || !module.exports.is(this)) {
|
||||
throw new TypeError("Illegal invocation");
|
||||
}
|
||||
|
||||
return this[impl]["childElementCount"];
|
||||
},
|
||||
|
||||
enumerable: true,
|
||||
configurable: true
|
||||
});
|
||||
|
||||
Object.defineProperty(DocumentFragment.prototype, Symbol.toStringTag, {
|
||||
value: "DocumentFragment",
|
||||
writable: false,
|
||||
enumerable: false,
|
||||
configurable: true
|
||||
});
|
||||
|
||||
const iface = {
|
||||
// When an interface-module that implements this interface as a mixin is loaded, it will append its own `.is()`
|
||||
// method into this array. It allows objects that directly implements *those* interfaces to be recognized as
|
||||
// implementing this mixin interface.
|
||||
_mixedIntoPredicates: [],
|
||||
is(obj) {
|
||||
if (obj) {
|
||||
if (utils.hasOwn(obj, impl) && obj[impl] instanceof Impl.implementation) {
|
||||
return true;
|
||||
}
|
||||
for (const isMixedInto of module.exports._mixedIntoPredicates) {
|
||||
if (isMixedInto(obj)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
},
|
||||
isImpl(obj) {
|
||||
if (obj) {
|
||||
if (obj instanceof Impl.implementation) {
|
||||
return true;
|
||||
if (!exports.is(esValue)) {
|
||||
throw new TypeError("Illegal invocation");
|
||||
}
|
||||
|
||||
const wrapper = utils.wrapperForImpl(obj);
|
||||
for (const isMixedInto of module.exports._mixedIntoPredicates) {
|
||||
if (isMixedInto(wrapper)) {
|
||||
return true;
|
||||
}
|
||||
return utils.tryWrapperForImpl(esValue[implSymbol]["firstElementChild"]);
|
||||
}
|
||||
|
||||
get lastElementChild() {
|
||||
const esValue = this !== null && this !== undefined ? this : globalObject;
|
||||
|
||||
if (!exports.is(esValue)) {
|
||||
throw new TypeError("Illegal invocation");
|
||||
}
|
||||
|
||||
return utils.tryWrapperForImpl(esValue[implSymbol]["lastElementChild"]);
|
||||
}
|
||||
return false;
|
||||
},
|
||||
convert(obj, { context = "The provided value" } = {}) {
|
||||
if (module.exports.is(obj)) {
|
||||
return utils.implForWrapper(obj);
|
||||
|
||||
get childElementCount() {
|
||||
const esValue = this !== null && this !== undefined ? this : globalObject;
|
||||
|
||||
if (!exports.is(esValue)) {
|
||||
throw new TypeError("Illegal invocation");
|
||||
}
|
||||
|
||||
return esValue[implSymbol]["childElementCount"];
|
||||
}
|
||||
throw new TypeError(`${context} is not of type 'DocumentFragment'.`);
|
||||
},
|
||||
|
||||
create(constructorArgs, privateData) {
|
||||
let obj = Object.create(DocumentFragment.prototype);
|
||||
obj = this.setup(obj, constructorArgs, privateData);
|
||||
return obj;
|
||||
},
|
||||
createImpl(constructorArgs, privateData) {
|
||||
let obj = Object.create(DocumentFragment.prototype);
|
||||
obj = this.setup(obj, constructorArgs, privateData);
|
||||
return utils.implForWrapper(obj);
|
||||
},
|
||||
_internalSetup(obj) {
|
||||
Node._internalSetup(obj);
|
||||
},
|
||||
setup(obj, constructorArgs, privateData) {
|
||||
if (!privateData) privateData = {};
|
||||
|
||||
privateData.wrapper = obj;
|
||||
|
||||
this._internalSetup(obj);
|
||||
Object.defineProperty(obj, impl, {
|
||||
value: new Impl.implementation(constructorArgs, privateData),
|
||||
writable: false,
|
||||
enumerable: false,
|
||||
configurable: true
|
||||
});
|
||||
|
||||
obj[impl][utils.wrapperSymbol] = obj;
|
||||
if (Impl.init) {
|
||||
Impl.init(obj[impl], privateData);
|
||||
}
|
||||
return obj;
|
||||
},
|
||||
interface: DocumentFragment,
|
||||
expose: {
|
||||
Window: { DocumentFragment }
|
||||
}
|
||||
}; // iface
|
||||
module.exports = iface;
|
||||
Object.defineProperties(DocumentFragment.prototype, {
|
||||
getElementById: { enumerable: true },
|
||||
prepend: { enumerable: true },
|
||||
append: { enumerable: true },
|
||||
querySelector: { enumerable: true },
|
||||
querySelectorAll: { enumerable: true },
|
||||
children: { enumerable: true },
|
||||
firstElementChild: { enumerable: true },
|
||||
lastElementChild: { enumerable: true },
|
||||
childElementCount: { enumerable: true },
|
||||
[Symbol.toStringTag]: { value: "DocumentFragment", configurable: true },
|
||||
[Symbol.unscopables]: { value: { prepend: true, append: true, __proto__: null }, configurable: true }
|
||||
});
|
||||
if (globalObject[ctorRegistrySymbol] === undefined) {
|
||||
globalObject[ctorRegistrySymbol] = Object.create(null);
|
||||
}
|
||||
globalObject[ctorRegistrySymbol][interfaceName] = DocumentFragment;
|
||||
|
||||
NonElementParentNode._mixedIntoPredicates.push(module.exports.is);
|
||||
|
||||
ParentNode._mixedIntoPredicates.push(module.exports.is);
|
||||
Object.defineProperty(globalObject, interfaceName, {
|
||||
configurable: true,
|
||||
writable: true,
|
||||
value: DocumentFragment
|
||||
});
|
||||
};
|
||||
|
||||
const Impl = require("../nodes/DocumentFragment-impl.js");
|
||||
|
||||
15
node_modules/jsdom/lib/jsdom/living/generated/DocumentReadyState.js
generated
vendored
15
node_modules/jsdom/lib/jsdom/living/generated/DocumentReadyState.js
generated
vendored
@@ -1,13 +1,12 @@
|
||||
"use strict";
|
||||
|
||||
const enumerationValues = new Set(["loading", "interactive", "complete"]);
|
||||
module.exports = {
|
||||
enumerationValues,
|
||||
convert(value, { context = "The provided value" } = {}) {
|
||||
const string = `${value}`;
|
||||
if (!enumerationValues.has(value)) {
|
||||
throw new TypeError(`${context} '${value}' is not a valid enumeration value for DocumentReadyState`);
|
||||
}
|
||||
return string;
|
||||
exports.enumerationValues = enumerationValues;
|
||||
|
||||
exports.convert = function convert(value, { context = "The provided value" } = {}) {
|
||||
const string = `${value}`;
|
||||
if (!enumerationValues.has(string)) {
|
||||
throw new TypeError(`${context} '${string}' is not a valid enumeration value for DocumentReadyState`);
|
||||
}
|
||||
return string;
|
||||
};
|
||||
|
||||
387
node_modules/jsdom/lib/jsdom/living/generated/DocumentType.js
generated
vendored
387
node_modules/jsdom/lib/jsdom/living/generated/DocumentType.js
generated
vendored
@@ -3,215 +3,244 @@
|
||||
const conversions = require("webidl-conversions");
|
||||
const utils = require("./utils.js");
|
||||
|
||||
const isNode = require("./Node.js").is;
|
||||
const impl = utils.implSymbol;
|
||||
const Node = require("./Node.js");
|
||||
const ChildNode = require("./ChildNode.js");
|
||||
const ceReactionsPreSteps_helpers_custom_elements = require("../helpers/custom-elements.js").ceReactionsPreSteps;
|
||||
const ceReactionsPostSteps_helpers_custom_elements = require("../helpers/custom-elements.js").ceReactionsPostSteps;
|
||||
const implSymbol = utils.implSymbol;
|
||||
const ctorRegistrySymbol = utils.ctorRegistrySymbol;
|
||||
|
||||
function DocumentType() {
|
||||
throw new TypeError("Illegal constructor");
|
||||
const interfaceName = "DocumentType";
|
||||
|
||||
exports.is = value => {
|
||||
return utils.isObject(value) && utils.hasOwn(value, implSymbol) && value[implSymbol] instanceof Impl.implementation;
|
||||
};
|
||||
exports.isImpl = value => {
|
||||
return utils.isObject(value) && value instanceof Impl.implementation;
|
||||
};
|
||||
exports.convert = (value, { context = "The provided value" } = {}) => {
|
||||
if (exports.is(value)) {
|
||||
return utils.implForWrapper(value);
|
||||
}
|
||||
throw new TypeError(`${context} is not of type 'DocumentType'.`);
|
||||
};
|
||||
|
||||
function makeWrapper(globalObject) {
|
||||
if (globalObject[ctorRegistrySymbol] === undefined) {
|
||||
throw new Error("Internal error: invalid global object");
|
||||
}
|
||||
|
||||
const ctor = globalObject[ctorRegistrySymbol]["DocumentType"];
|
||||
if (ctor === undefined) {
|
||||
throw new Error("Internal error: constructor DocumentType is not installed on the passed global object");
|
||||
}
|
||||
|
||||
return Object.create(ctor.prototype);
|
||||
}
|
||||
|
||||
Object.setPrototypeOf(DocumentType.prototype, Node.interface.prototype);
|
||||
Object.setPrototypeOf(DocumentType, Node.interface);
|
||||
|
||||
Object.defineProperty(DocumentType, "prototype", {
|
||||
value: DocumentType.prototype,
|
||||
writable: false,
|
||||
enumerable: false,
|
||||
configurable: false
|
||||
});
|
||||
|
||||
DocumentType.prototype.before = function before() {
|
||||
if (!this || !module.exports.is(this)) {
|
||||
throw new TypeError("Illegal invocation");
|
||||
}
|
||||
const args = [];
|
||||
for (let i = 0; i < arguments.length; i++) {
|
||||
let curArg = arguments[i];
|
||||
if (isNode(curArg)) {
|
||||
curArg = utils.implForWrapper(curArg);
|
||||
} else {
|
||||
curArg = conversions["DOMString"](curArg, {
|
||||
context: "Failed to execute 'before' on 'DocumentType': parameter " + (i + 1)
|
||||
});
|
||||
}
|
||||
args.push(curArg);
|
||||
}
|
||||
return this[impl].before(...args);
|
||||
exports.create = (globalObject, constructorArgs, privateData) => {
|
||||
const wrapper = makeWrapper(globalObject);
|
||||
return exports.setup(wrapper, globalObject, constructorArgs, privateData);
|
||||
};
|
||||
|
||||
DocumentType.prototype.after = function after() {
|
||||
if (!this || !module.exports.is(this)) {
|
||||
throw new TypeError("Illegal invocation");
|
||||
}
|
||||
const args = [];
|
||||
for (let i = 0; i < arguments.length; i++) {
|
||||
let curArg = arguments[i];
|
||||
if (isNode(curArg)) {
|
||||
curArg = utils.implForWrapper(curArg);
|
||||
} else {
|
||||
curArg = conversions["DOMString"](curArg, {
|
||||
context: "Failed to execute 'after' on 'DocumentType': parameter " + (i + 1)
|
||||
});
|
||||
}
|
||||
args.push(curArg);
|
||||
}
|
||||
return this[impl].after(...args);
|
||||
exports.createImpl = (globalObject, constructorArgs, privateData) => {
|
||||
const wrapper = exports.create(globalObject, constructorArgs, privateData);
|
||||
return utils.implForWrapper(wrapper);
|
||||
};
|
||||
|
||||
DocumentType.prototype.replaceWith = function replaceWith() {
|
||||
if (!this || !module.exports.is(this)) {
|
||||
throw new TypeError("Illegal invocation");
|
||||
}
|
||||
const args = [];
|
||||
for (let i = 0; i < arguments.length; i++) {
|
||||
let curArg = arguments[i];
|
||||
if (isNode(curArg)) {
|
||||
curArg = utils.implForWrapper(curArg);
|
||||
} else {
|
||||
curArg = conversions["DOMString"](curArg, {
|
||||
context: "Failed to execute 'replaceWith' on 'DocumentType': parameter " + (i + 1)
|
||||
});
|
||||
}
|
||||
args.push(curArg);
|
||||
}
|
||||
return this[impl].replaceWith(...args);
|
||||
exports._internalSetup = (wrapper, globalObject) => {
|
||||
Node._internalSetup(wrapper, globalObject);
|
||||
};
|
||||
|
||||
DocumentType.prototype.remove = function remove() {
|
||||
if (!this || !module.exports.is(this)) {
|
||||
throw new TypeError("Illegal invocation");
|
||||
}
|
||||
exports.setup = (wrapper, globalObject, constructorArgs = [], privateData = {}) => {
|
||||
privateData.wrapper = wrapper;
|
||||
|
||||
return this[impl].remove();
|
||||
exports._internalSetup(wrapper, globalObject);
|
||||
Object.defineProperty(wrapper, implSymbol, {
|
||||
value: new Impl.implementation(globalObject, constructorArgs, privateData),
|
||||
configurable: true
|
||||
});
|
||||
|
||||
wrapper[implSymbol][utils.wrapperSymbol] = wrapper;
|
||||
if (Impl.init) {
|
||||
Impl.init(wrapper[implSymbol]);
|
||||
}
|
||||
return wrapper;
|
||||
};
|
||||
|
||||
Object.defineProperty(DocumentType.prototype, "name", {
|
||||
get() {
|
||||
if (!this || !module.exports.is(this)) {
|
||||
throw new TypeError("Illegal invocation");
|
||||
exports.new = globalObject => {
|
||||
const wrapper = makeWrapper(globalObject);
|
||||
|
||||
exports._internalSetup(wrapper, globalObject);
|
||||
Object.defineProperty(wrapper, implSymbol, {
|
||||
value: Object.create(Impl.implementation.prototype),
|
||||
configurable: true
|
||||
});
|
||||
|
||||
wrapper[implSymbol][utils.wrapperSymbol] = wrapper;
|
||||
if (Impl.init) {
|
||||
Impl.init(wrapper[implSymbol]);
|
||||
}
|
||||
return wrapper[implSymbol];
|
||||
};
|
||||
|
||||
const exposed = new Set(["Window"]);
|
||||
|
||||
exports.install = (globalObject, globalNames) => {
|
||||
if (!globalNames.some(globalName => exposed.has(globalName))) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (globalObject.Node === undefined) {
|
||||
throw new Error("Internal error: attempting to evaluate DocumentType before Node");
|
||||
}
|
||||
class DocumentType extends globalObject.Node {
|
||||
constructor() {
|
||||
throw new TypeError("Illegal constructor");
|
||||
}
|
||||
|
||||
return this[impl]["name"];
|
||||
},
|
||||
|
||||
enumerable: true,
|
||||
configurable: true
|
||||
});
|
||||
|
||||
Object.defineProperty(DocumentType.prototype, "publicId", {
|
||||
get() {
|
||||
if (!this || !module.exports.is(this)) {
|
||||
throw new TypeError("Illegal invocation");
|
||||
}
|
||||
|
||||
return this[impl]["publicId"];
|
||||
},
|
||||
|
||||
enumerable: true,
|
||||
configurable: true
|
||||
});
|
||||
|
||||
Object.defineProperty(DocumentType.prototype, "systemId", {
|
||||
get() {
|
||||
if (!this || !module.exports.is(this)) {
|
||||
throw new TypeError("Illegal invocation");
|
||||
}
|
||||
|
||||
return this[impl]["systemId"];
|
||||
},
|
||||
|
||||
enumerable: true,
|
||||
configurable: true
|
||||
});
|
||||
|
||||
Object.defineProperty(DocumentType.prototype, Symbol.toStringTag, {
|
||||
value: "DocumentType",
|
||||
writable: false,
|
||||
enumerable: false,
|
||||
configurable: true
|
||||
});
|
||||
|
||||
const iface = {
|
||||
// When an interface-module that implements this interface as a mixin is loaded, it will append its own `.is()`
|
||||
// method into this array. It allows objects that directly implements *those* interfaces to be recognized as
|
||||
// implementing this mixin interface.
|
||||
_mixedIntoPredicates: [],
|
||||
is(obj) {
|
||||
if (obj) {
|
||||
if (utils.hasOwn(obj, impl) && obj[impl] instanceof Impl.implementation) {
|
||||
return true;
|
||||
before() {
|
||||
const esValue = this !== null && this !== undefined ? this : globalObject;
|
||||
if (!exports.is(esValue)) {
|
||||
throw new TypeError("Illegal invocation");
|
||||
}
|
||||
for (const isMixedInto of module.exports._mixedIntoPredicates) {
|
||||
if (isMixedInto(obj)) {
|
||||
return true;
|
||||
const args = [];
|
||||
for (let i = 0; i < arguments.length; i++) {
|
||||
let curArg = arguments[i];
|
||||
if (Node.is(curArg)) {
|
||||
curArg = utils.implForWrapper(curArg);
|
||||
} else {
|
||||
curArg = conversions["DOMString"](curArg, {
|
||||
context: "Failed to execute 'before' on 'DocumentType': parameter " + (i + 1)
|
||||
});
|
||||
}
|
||||
args.push(curArg);
|
||||
}
|
||||
ceReactionsPreSteps_helpers_custom_elements(globalObject);
|
||||
try {
|
||||
return esValue[implSymbol].before(...args);
|
||||
} finally {
|
||||
ceReactionsPostSteps_helpers_custom_elements(globalObject);
|
||||
}
|
||||
}
|
||||
return false;
|
||||
},
|
||||
isImpl(obj) {
|
||||
if (obj) {
|
||||
if (obj instanceof Impl.implementation) {
|
||||
return true;
|
||||
}
|
||||
|
||||
const wrapper = utils.wrapperForImpl(obj);
|
||||
for (const isMixedInto of module.exports._mixedIntoPredicates) {
|
||||
if (isMixedInto(wrapper)) {
|
||||
return true;
|
||||
after() {
|
||||
const esValue = this !== null && this !== undefined ? this : globalObject;
|
||||
if (!exports.is(esValue)) {
|
||||
throw new TypeError("Illegal invocation");
|
||||
}
|
||||
const args = [];
|
||||
for (let i = 0; i < arguments.length; i++) {
|
||||
let curArg = arguments[i];
|
||||
if (Node.is(curArg)) {
|
||||
curArg = utils.implForWrapper(curArg);
|
||||
} else {
|
||||
curArg = conversions["DOMString"](curArg, {
|
||||
context: "Failed to execute 'after' on 'DocumentType': parameter " + (i + 1)
|
||||
});
|
||||
}
|
||||
args.push(curArg);
|
||||
}
|
||||
ceReactionsPreSteps_helpers_custom_elements(globalObject);
|
||||
try {
|
||||
return esValue[implSymbol].after(...args);
|
||||
} finally {
|
||||
ceReactionsPostSteps_helpers_custom_elements(globalObject);
|
||||
}
|
||||
}
|
||||
return false;
|
||||
},
|
||||
convert(obj, { context = "The provided value" } = {}) {
|
||||
if (module.exports.is(obj)) {
|
||||
return utils.implForWrapper(obj);
|
||||
|
||||
replaceWith() {
|
||||
const esValue = this !== null && this !== undefined ? this : globalObject;
|
||||
if (!exports.is(esValue)) {
|
||||
throw new TypeError("Illegal invocation");
|
||||
}
|
||||
const args = [];
|
||||
for (let i = 0; i < arguments.length; i++) {
|
||||
let curArg = arguments[i];
|
||||
if (Node.is(curArg)) {
|
||||
curArg = utils.implForWrapper(curArg);
|
||||
} else {
|
||||
curArg = conversions["DOMString"](curArg, {
|
||||
context: "Failed to execute 'replaceWith' on 'DocumentType': parameter " + (i + 1)
|
||||
});
|
||||
}
|
||||
args.push(curArg);
|
||||
}
|
||||
ceReactionsPreSteps_helpers_custom_elements(globalObject);
|
||||
try {
|
||||
return esValue[implSymbol].replaceWith(...args);
|
||||
} finally {
|
||||
ceReactionsPostSteps_helpers_custom_elements(globalObject);
|
||||
}
|
||||
}
|
||||
throw new TypeError(`${context} is not of type 'DocumentType'.`);
|
||||
},
|
||||
|
||||
create(constructorArgs, privateData) {
|
||||
let obj = Object.create(DocumentType.prototype);
|
||||
obj = this.setup(obj, constructorArgs, privateData);
|
||||
return obj;
|
||||
},
|
||||
createImpl(constructorArgs, privateData) {
|
||||
let obj = Object.create(DocumentType.prototype);
|
||||
obj = this.setup(obj, constructorArgs, privateData);
|
||||
return utils.implForWrapper(obj);
|
||||
},
|
||||
_internalSetup(obj) {
|
||||
Node._internalSetup(obj);
|
||||
},
|
||||
setup(obj, constructorArgs, privateData) {
|
||||
if (!privateData) privateData = {};
|
||||
remove() {
|
||||
const esValue = this !== null && this !== undefined ? this : globalObject;
|
||||
if (!exports.is(esValue)) {
|
||||
throw new TypeError("Illegal invocation");
|
||||
}
|
||||
|
||||
privateData.wrapper = obj;
|
||||
ceReactionsPreSteps_helpers_custom_elements(globalObject);
|
||||
try {
|
||||
return esValue[implSymbol].remove();
|
||||
} finally {
|
||||
ceReactionsPostSteps_helpers_custom_elements(globalObject);
|
||||
}
|
||||
}
|
||||
|
||||
this._internalSetup(obj);
|
||||
Object.defineProperty(obj, impl, {
|
||||
value: new Impl.implementation(constructorArgs, privateData),
|
||||
writable: false,
|
||||
enumerable: false,
|
||||
get name() {
|
||||
const esValue = this !== null && this !== undefined ? this : globalObject;
|
||||
|
||||
if (!exports.is(esValue)) {
|
||||
throw new TypeError("Illegal invocation");
|
||||
}
|
||||
|
||||
return esValue[implSymbol]["name"];
|
||||
}
|
||||
|
||||
get publicId() {
|
||||
const esValue = this !== null && this !== undefined ? this : globalObject;
|
||||
|
||||
if (!exports.is(esValue)) {
|
||||
throw new TypeError("Illegal invocation");
|
||||
}
|
||||
|
||||
return esValue[implSymbol]["publicId"];
|
||||
}
|
||||
|
||||
get systemId() {
|
||||
const esValue = this !== null && this !== undefined ? this : globalObject;
|
||||
|
||||
if (!exports.is(esValue)) {
|
||||
throw new TypeError("Illegal invocation");
|
||||
}
|
||||
|
||||
return esValue[implSymbol]["systemId"];
|
||||
}
|
||||
}
|
||||
Object.defineProperties(DocumentType.prototype, {
|
||||
before: { enumerable: true },
|
||||
after: { enumerable: true },
|
||||
replaceWith: { enumerable: true },
|
||||
remove: { enumerable: true },
|
||||
name: { enumerable: true },
|
||||
publicId: { enumerable: true },
|
||||
systemId: { enumerable: true },
|
||||
[Symbol.toStringTag]: { value: "DocumentType", configurable: true },
|
||||
[Symbol.unscopables]: {
|
||||
value: { before: true, after: true, replaceWith: true, remove: true, __proto__: null },
|
||||
configurable: true
|
||||
});
|
||||
|
||||
obj[impl][utils.wrapperSymbol] = obj;
|
||||
if (Impl.init) {
|
||||
Impl.init(obj[impl], privateData);
|
||||
}
|
||||
return obj;
|
||||
},
|
||||
interface: DocumentType,
|
||||
expose: {
|
||||
Window: { DocumentType }
|
||||
});
|
||||
if (globalObject[ctorRegistrySymbol] === undefined) {
|
||||
globalObject[ctorRegistrySymbol] = Object.create(null);
|
||||
}
|
||||
}; // iface
|
||||
module.exports = iface;
|
||||
globalObject[ctorRegistrySymbol][interfaceName] = DocumentType;
|
||||
|
||||
ChildNode._mixedIntoPredicates.push(module.exports.is);
|
||||
Object.defineProperty(globalObject, interfaceName, {
|
||||
configurable: true,
|
||||
writable: true,
|
||||
value: DocumentType
|
||||
});
|
||||
};
|
||||
|
||||
const Impl = require("../nodes/DocumentType-impl.js");
|
||||
|
||||
2712
node_modules/jsdom/lib/jsdom/living/generated/Element.js
generated
vendored
2712
node_modules/jsdom/lib/jsdom/living/generated/Element.js
generated
vendored
File diff suppressed because it is too large
Load Diff
124
node_modules/jsdom/lib/jsdom/living/generated/ElementCSSInlineStyle.js
generated
vendored
124
node_modules/jsdom/lib/jsdom/living/generated/ElementCSSInlineStyle.js
generated
vendored
@@ -1,124 +0,0 @@
|
||||
"use strict";
|
||||
|
||||
const conversions = require("webidl-conversions");
|
||||
const utils = require("./utils.js");
|
||||
|
||||
const impl = utils.implSymbol;
|
||||
|
||||
function ElementCSSInlineStyle() {
|
||||
throw new TypeError("Illegal constructor");
|
||||
}
|
||||
|
||||
Object.defineProperty(ElementCSSInlineStyle, "prototype", {
|
||||
value: ElementCSSInlineStyle.prototype,
|
||||
writable: false,
|
||||
enumerable: false,
|
||||
configurable: false
|
||||
});
|
||||
|
||||
Object.defineProperty(ElementCSSInlineStyle.prototype, "style", {
|
||||
get() {
|
||||
if (!this || !module.exports.is(this)) {
|
||||
throw new TypeError("Illegal invocation");
|
||||
}
|
||||
|
||||
return utils.getSameObject(this, "style", () => {
|
||||
return utils.tryWrapperForImpl(this[impl]["style"]);
|
||||
});
|
||||
},
|
||||
|
||||
set(V) {
|
||||
if (!this || !module.exports.is(this)) {
|
||||
throw new TypeError("Illegal invocation");
|
||||
}
|
||||
|
||||
this.style.cssText = V;
|
||||
},
|
||||
|
||||
enumerable: true,
|
||||
configurable: true
|
||||
});
|
||||
|
||||
Object.defineProperty(ElementCSSInlineStyle.prototype, Symbol.toStringTag, {
|
||||
value: "ElementCSSInlineStyle",
|
||||
writable: false,
|
||||
enumerable: false,
|
||||
configurable: true
|
||||
});
|
||||
|
||||
const iface = {
|
||||
// When an interface-module that implements this interface as a mixin is loaded, it will append its own `.is()`
|
||||
// method into this array. It allows objects that directly implements *those* interfaces to be recognized as
|
||||
// implementing this mixin interface.
|
||||
_mixedIntoPredicates: [],
|
||||
is(obj) {
|
||||
if (obj) {
|
||||
if (utils.hasOwn(obj, impl) && obj[impl] instanceof Impl.implementation) {
|
||||
return true;
|
||||
}
|
||||
for (const isMixedInto of module.exports._mixedIntoPredicates) {
|
||||
if (isMixedInto(obj)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
},
|
||||
isImpl(obj) {
|
||||
if (obj) {
|
||||
if (obj instanceof Impl.implementation) {
|
||||
return true;
|
||||
}
|
||||
|
||||
const wrapper = utils.wrapperForImpl(obj);
|
||||
for (const isMixedInto of module.exports._mixedIntoPredicates) {
|
||||
if (isMixedInto(wrapper)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
},
|
||||
convert(obj, { context = "The provided value" } = {}) {
|
||||
if (module.exports.is(obj)) {
|
||||
return utils.implForWrapper(obj);
|
||||
}
|
||||
throw new TypeError(`${context} is not of type 'ElementCSSInlineStyle'.`);
|
||||
},
|
||||
|
||||
create(constructorArgs, privateData) {
|
||||
let obj = Object.create(ElementCSSInlineStyle.prototype);
|
||||
obj = this.setup(obj, constructorArgs, privateData);
|
||||
return obj;
|
||||
},
|
||||
createImpl(constructorArgs, privateData) {
|
||||
let obj = Object.create(ElementCSSInlineStyle.prototype);
|
||||
obj = this.setup(obj, constructorArgs, privateData);
|
||||
return utils.implForWrapper(obj);
|
||||
},
|
||||
_internalSetup(obj) {},
|
||||
setup(obj, constructorArgs, privateData) {
|
||||
if (!privateData) privateData = {};
|
||||
|
||||
privateData.wrapper = obj;
|
||||
|
||||
this._internalSetup(obj);
|
||||
Object.defineProperty(obj, impl, {
|
||||
value: new Impl.implementation(constructorArgs, privateData),
|
||||
writable: false,
|
||||
enumerable: false,
|
||||
configurable: true
|
||||
});
|
||||
|
||||
obj[impl][utils.wrapperSymbol] = obj;
|
||||
if (Impl.init) {
|
||||
Impl.init(obj[impl], privateData);
|
||||
}
|
||||
return obj;
|
||||
},
|
||||
interface: ElementCSSInlineStyle,
|
||||
expose: {}
|
||||
}; // iface
|
||||
module.exports = iface;
|
||||
|
||||
const Impl = require("../nodes/ElementCSSInlineStyle-impl.js");
|
||||
101
node_modules/jsdom/lib/jsdom/living/generated/ElementContentEditable.js
generated
vendored
101
node_modules/jsdom/lib/jsdom/living/generated/ElementContentEditable.js
generated
vendored
@@ -1,101 +0,0 @@
|
||||
"use strict";
|
||||
|
||||
const conversions = require("webidl-conversions");
|
||||
const utils = require("./utils.js");
|
||||
|
||||
const impl = utils.implSymbol;
|
||||
|
||||
function ElementContentEditable() {
|
||||
throw new TypeError("Illegal constructor");
|
||||
}
|
||||
|
||||
Object.defineProperty(ElementContentEditable, "prototype", {
|
||||
value: ElementContentEditable.prototype,
|
||||
writable: false,
|
||||
enumerable: false,
|
||||
configurable: false
|
||||
});
|
||||
|
||||
Object.defineProperty(ElementContentEditable.prototype, Symbol.toStringTag, {
|
||||
value: "ElementContentEditable",
|
||||
writable: false,
|
||||
enumerable: false,
|
||||
configurable: true
|
||||
});
|
||||
|
||||
const iface = {
|
||||
// When an interface-module that implements this interface as a mixin is loaded, it will append its own `.is()`
|
||||
// method into this array. It allows objects that directly implements *those* interfaces to be recognized as
|
||||
// implementing this mixin interface.
|
||||
_mixedIntoPredicates: [],
|
||||
is(obj) {
|
||||
if (obj) {
|
||||
if (utils.hasOwn(obj, impl) && obj[impl] instanceof Impl.implementation) {
|
||||
return true;
|
||||
}
|
||||
for (const isMixedInto of module.exports._mixedIntoPredicates) {
|
||||
if (isMixedInto(obj)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
},
|
||||
isImpl(obj) {
|
||||
if (obj) {
|
||||
if (obj instanceof Impl.implementation) {
|
||||
return true;
|
||||
}
|
||||
|
||||
const wrapper = utils.wrapperForImpl(obj);
|
||||
for (const isMixedInto of module.exports._mixedIntoPredicates) {
|
||||
if (isMixedInto(wrapper)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
},
|
||||
convert(obj, { context = "The provided value" } = {}) {
|
||||
if (module.exports.is(obj)) {
|
||||
return utils.implForWrapper(obj);
|
||||
}
|
||||
throw new TypeError(`${context} is not of type 'ElementContentEditable'.`);
|
||||
},
|
||||
|
||||
create(constructorArgs, privateData) {
|
||||
let obj = Object.create(ElementContentEditable.prototype);
|
||||
obj = this.setup(obj, constructorArgs, privateData);
|
||||
return obj;
|
||||
},
|
||||
createImpl(constructorArgs, privateData) {
|
||||
let obj = Object.create(ElementContentEditable.prototype);
|
||||
obj = this.setup(obj, constructorArgs, privateData);
|
||||
return utils.implForWrapper(obj);
|
||||
},
|
||||
_internalSetup(obj) {},
|
||||
setup(obj, constructorArgs, privateData) {
|
||||
if (!privateData) privateData = {};
|
||||
|
||||
privateData.wrapper = obj;
|
||||
|
||||
this._internalSetup(obj);
|
||||
Object.defineProperty(obj, impl, {
|
||||
value: new Impl.implementation(constructorArgs, privateData),
|
||||
writable: false,
|
||||
enumerable: false,
|
||||
configurable: true
|
||||
});
|
||||
|
||||
obj[impl][utils.wrapperSymbol] = obj;
|
||||
if (Impl.init) {
|
||||
Impl.init(obj[impl], privateData);
|
||||
}
|
||||
return obj;
|
||||
},
|
||||
interface: ElementContentEditable,
|
||||
expose: {}
|
||||
}; // iface
|
||||
module.exports = iface;
|
||||
|
||||
const Impl = require("../nodes/ElementContentEditable-impl.js");
|
||||
36
node_modules/jsdom/lib/jsdom/living/generated/ElementCreationOptions.js
generated
vendored
36
node_modules/jsdom/lib/jsdom/living/generated/ElementCreationOptions.js
generated
vendored
@@ -3,26 +3,24 @@
|
||||
const conversions = require("webidl-conversions");
|
||||
const utils = require("./utils.js");
|
||||
|
||||
module.exports = {
|
||||
convertInherit(obj, ret, { context = "The provided value" } = {}) {
|
||||
{
|
||||
const key = "is";
|
||||
let value = obj === undefined || obj === null ? undefined : obj[key];
|
||||
if (value !== undefined) {
|
||||
value = conversions["DOMString"](value, { context: context + " has member is that" });
|
||||
exports._convertInherit = (obj, ret, { context = "The provided value" } = {}) => {
|
||||
{
|
||||
const key = "is";
|
||||
let value = obj === undefined || obj === null ? undefined : obj[key];
|
||||
if (value !== undefined) {
|
||||
value = conversions["DOMString"](value, { context: context + " has member 'is' that" });
|
||||
|
||||
ret[key] = value;
|
||||
}
|
||||
ret[key] = value;
|
||||
}
|
||||
},
|
||||
|
||||
convert(obj, { context = "The provided value" } = {}) {
|
||||
if (obj !== undefined && typeof obj !== "object" && typeof obj !== "function") {
|
||||
throw new TypeError(`${context} is not an object.`);
|
||||
}
|
||||
|
||||
const ret = Object.create(null);
|
||||
module.exports.convertInherit(obj, ret, { context });
|
||||
return ret;
|
||||
}
|
||||
};
|
||||
|
||||
exports.convert = function convert(obj, { context = "The provided value" } = {}) {
|
||||
if (obj !== undefined && typeof obj !== "object" && typeof obj !== "function") {
|
||||
throw new TypeError(`${context} is not an object.`);
|
||||
}
|
||||
|
||||
const ret = Object.create(null);
|
||||
exports._convertInherit(obj, ret, { context });
|
||||
return ret;
|
||||
};
|
||||
|
||||
26
node_modules/jsdom/lib/jsdom/living/generated/ElementDefinitionOptions.js
generated
vendored
Normal file
26
node_modules/jsdom/lib/jsdom/living/generated/ElementDefinitionOptions.js
generated
vendored
Normal file
@@ -0,0 +1,26 @@
|
||||
"use strict";
|
||||
|
||||
const conversions = require("webidl-conversions");
|
||||
const utils = require("./utils.js");
|
||||
|
||||
exports._convertInherit = (obj, ret, { context = "The provided value" } = {}) => {
|
||||
{
|
||||
const key = "extends";
|
||||
let value = obj === undefined || obj === null ? undefined : obj[key];
|
||||
if (value !== undefined) {
|
||||
value = conversions["DOMString"](value, { context: context + " has member 'extends' that" });
|
||||
|
||||
ret[key] = value;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
exports.convert = function convert(obj, { context = "The provided value" } = {}) {
|
||||
if (obj !== undefined && typeof obj !== "object" && typeof obj !== "function") {
|
||||
throw new TypeError(`${context} is not an object.`);
|
||||
}
|
||||
|
||||
const ret = Object.create(null);
|
||||
exports._convertInherit(obj, ret, { context });
|
||||
return ret;
|
||||
};
|
||||
15
node_modules/jsdom/lib/jsdom/living/generated/EndingType.js
generated
vendored
15
node_modules/jsdom/lib/jsdom/living/generated/EndingType.js
generated
vendored
@@ -1,13 +1,12 @@
|
||||
"use strict";
|
||||
|
||||
const enumerationValues = new Set(["transparent", "native"]);
|
||||
module.exports = {
|
||||
enumerationValues,
|
||||
convert(value, { context = "The provided value" } = {}) {
|
||||
const string = `${value}`;
|
||||
if (!enumerationValues.has(value)) {
|
||||
throw new TypeError(`${context} '${value}' is not a valid enumeration value for EndingType`);
|
||||
}
|
||||
return string;
|
||||
exports.enumerationValues = enumerationValues;
|
||||
|
||||
exports.convert = function convert(value, { context = "The provided value" } = {}) {
|
||||
const string = `${value}`;
|
||||
if (!enumerationValues.has(string)) {
|
||||
throw new TypeError(`${context} '${string}' is not a valid enumeration value for EndingType`);
|
||||
}
|
||||
return string;
|
||||
};
|
||||
|
||||
344
node_modules/jsdom/lib/jsdom/living/generated/ErrorEvent.js
generated
vendored
344
node_modules/jsdom/lib/jsdom/living/generated/ErrorEvent.js
generated
vendored
@@ -3,198 +3,184 @@
|
||||
const conversions = require("webidl-conversions");
|
||||
const utils = require("./utils.js");
|
||||
|
||||
const convertErrorEventInit = require("./ErrorEventInit.js").convert;
|
||||
const impl = utils.implSymbol;
|
||||
const ErrorEventInit = require("./ErrorEventInit.js");
|
||||
const implSymbol = utils.implSymbol;
|
||||
const ctorRegistrySymbol = utils.ctorRegistrySymbol;
|
||||
const Event = require("./Event.js");
|
||||
|
||||
function ErrorEvent(type) {
|
||||
if (new.target === undefined) {
|
||||
throw new TypeError(
|
||||
"Failed to construct 'ErrorEvent'. Please use the 'new' operator; this constructor " +
|
||||
"cannot be called as a function."
|
||||
);
|
||||
const interfaceName = "ErrorEvent";
|
||||
|
||||
exports.is = value => {
|
||||
return utils.isObject(value) && utils.hasOwn(value, implSymbol) && value[implSymbol] instanceof Impl.implementation;
|
||||
};
|
||||
exports.isImpl = value => {
|
||||
return utils.isObject(value) && value instanceof Impl.implementation;
|
||||
};
|
||||
exports.convert = (value, { context = "The provided value" } = {}) => {
|
||||
if (exports.is(value)) {
|
||||
return utils.implForWrapper(value);
|
||||
}
|
||||
throw new TypeError(`${context} is not of type 'ErrorEvent'.`);
|
||||
};
|
||||
|
||||
function makeWrapper(globalObject) {
|
||||
if (globalObject[ctorRegistrySymbol] === undefined) {
|
||||
throw new Error("Internal error: invalid global object");
|
||||
}
|
||||
|
||||
if (arguments.length < 1) {
|
||||
throw new TypeError(
|
||||
"Failed to construct 'ErrorEvent': 1 argument required, but only " + arguments.length + " present."
|
||||
);
|
||||
}
|
||||
const args = [];
|
||||
{
|
||||
let curArg = arguments[0];
|
||||
curArg = conversions["DOMString"](curArg, { context: "Failed to construct 'ErrorEvent': parameter 1" });
|
||||
args.push(curArg);
|
||||
}
|
||||
{
|
||||
let curArg = arguments[1];
|
||||
curArg = convertErrorEventInit(curArg, { context: "Failed to construct 'ErrorEvent': parameter 2" });
|
||||
args.push(curArg);
|
||||
const ctor = globalObject[ctorRegistrySymbol]["ErrorEvent"];
|
||||
if (ctor === undefined) {
|
||||
throw new Error("Internal error: constructor ErrorEvent is not installed on the passed global object");
|
||||
}
|
||||
|
||||
iface.setup(this, args);
|
||||
return Object.create(ctor.prototype);
|
||||
}
|
||||
|
||||
Object.setPrototypeOf(ErrorEvent.prototype, Event.interface.prototype);
|
||||
Object.setPrototypeOf(ErrorEvent, Event.interface);
|
||||
exports.create = (globalObject, constructorArgs, privateData) => {
|
||||
const wrapper = makeWrapper(globalObject);
|
||||
return exports.setup(wrapper, globalObject, constructorArgs, privateData);
|
||||
};
|
||||
|
||||
Object.defineProperty(ErrorEvent, "prototype", {
|
||||
value: ErrorEvent.prototype,
|
||||
writable: false,
|
||||
enumerable: false,
|
||||
configurable: false
|
||||
});
|
||||
exports.createImpl = (globalObject, constructorArgs, privateData) => {
|
||||
const wrapper = exports.create(globalObject, constructorArgs, privateData);
|
||||
return utils.implForWrapper(wrapper);
|
||||
};
|
||||
|
||||
Object.defineProperty(ErrorEvent.prototype, "message", {
|
||||
get() {
|
||||
if (!this || !module.exports.is(this)) {
|
||||
throw new TypeError("Illegal invocation");
|
||||
}
|
||||
exports._internalSetup = (wrapper, globalObject) => {
|
||||
Event._internalSetup(wrapper, globalObject);
|
||||
};
|
||||
|
||||
return this[impl]["message"];
|
||||
},
|
||||
exports.setup = (wrapper, globalObject, constructorArgs = [], privateData = {}) => {
|
||||
privateData.wrapper = wrapper;
|
||||
|
||||
enumerable: true,
|
||||
configurable: true
|
||||
});
|
||||
exports._internalSetup(wrapper, globalObject);
|
||||
Object.defineProperty(wrapper, implSymbol, {
|
||||
value: new Impl.implementation(globalObject, constructorArgs, privateData),
|
||||
configurable: true
|
||||
});
|
||||
|
||||
Object.defineProperty(ErrorEvent.prototype, "filename", {
|
||||
get() {
|
||||
if (!this || !module.exports.is(this)) {
|
||||
throw new TypeError("Illegal invocation");
|
||||
}
|
||||
|
||||
return this[impl]["filename"];
|
||||
},
|
||||
|
||||
enumerable: true,
|
||||
configurable: true
|
||||
});
|
||||
|
||||
Object.defineProperty(ErrorEvent.prototype, "lineno", {
|
||||
get() {
|
||||
if (!this || !module.exports.is(this)) {
|
||||
throw new TypeError("Illegal invocation");
|
||||
}
|
||||
|
||||
return this[impl]["lineno"];
|
||||
},
|
||||
|
||||
enumerable: true,
|
||||
configurable: true
|
||||
});
|
||||
|
||||
Object.defineProperty(ErrorEvent.prototype, "colno", {
|
||||
get() {
|
||||
if (!this || !module.exports.is(this)) {
|
||||
throw new TypeError("Illegal invocation");
|
||||
}
|
||||
|
||||
return this[impl]["colno"];
|
||||
},
|
||||
|
||||
enumerable: true,
|
||||
configurable: true
|
||||
});
|
||||
|
||||
Object.defineProperty(ErrorEvent.prototype, "error", {
|
||||
get() {
|
||||
if (!this || !module.exports.is(this)) {
|
||||
throw new TypeError("Illegal invocation");
|
||||
}
|
||||
|
||||
return this[impl]["error"];
|
||||
},
|
||||
|
||||
enumerable: true,
|
||||
configurable: true
|
||||
});
|
||||
|
||||
Object.defineProperty(ErrorEvent.prototype, Symbol.toStringTag, {
|
||||
value: "ErrorEvent",
|
||||
writable: false,
|
||||
enumerable: false,
|
||||
configurable: true
|
||||
});
|
||||
|
||||
const iface = {
|
||||
// When an interface-module that implements this interface as a mixin is loaded, it will append its own `.is()`
|
||||
// method into this array. It allows objects that directly implements *those* interfaces to be recognized as
|
||||
// implementing this mixin interface.
|
||||
_mixedIntoPredicates: [],
|
||||
is(obj) {
|
||||
if (obj) {
|
||||
if (utils.hasOwn(obj, impl) && obj[impl] instanceof Impl.implementation) {
|
||||
return true;
|
||||
}
|
||||
for (const isMixedInto of module.exports._mixedIntoPredicates) {
|
||||
if (isMixedInto(obj)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
},
|
||||
isImpl(obj) {
|
||||
if (obj) {
|
||||
if (obj instanceof Impl.implementation) {
|
||||
return true;
|
||||
}
|
||||
|
||||
const wrapper = utils.wrapperForImpl(obj);
|
||||
for (const isMixedInto of module.exports._mixedIntoPredicates) {
|
||||
if (isMixedInto(wrapper)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
},
|
||||
convert(obj, { context = "The provided value" } = {}) {
|
||||
if (module.exports.is(obj)) {
|
||||
return utils.implForWrapper(obj);
|
||||
}
|
||||
throw new TypeError(`${context} is not of type 'ErrorEvent'.`);
|
||||
},
|
||||
|
||||
create(constructorArgs, privateData) {
|
||||
let obj = Object.create(ErrorEvent.prototype);
|
||||
obj = this.setup(obj, constructorArgs, privateData);
|
||||
return obj;
|
||||
},
|
||||
createImpl(constructorArgs, privateData) {
|
||||
let obj = Object.create(ErrorEvent.prototype);
|
||||
obj = this.setup(obj, constructorArgs, privateData);
|
||||
return utils.implForWrapper(obj);
|
||||
},
|
||||
_internalSetup(obj) {
|
||||
Event._internalSetup(obj);
|
||||
},
|
||||
setup(obj, constructorArgs, privateData) {
|
||||
if (!privateData) privateData = {};
|
||||
|
||||
privateData.wrapper = obj;
|
||||
|
||||
this._internalSetup(obj);
|
||||
Object.defineProperty(obj, impl, {
|
||||
value: new Impl.implementation(constructorArgs, privateData),
|
||||
writable: false,
|
||||
enumerable: false,
|
||||
configurable: true
|
||||
});
|
||||
|
||||
obj[impl][utils.wrapperSymbol] = obj;
|
||||
if (Impl.init) {
|
||||
Impl.init(obj[impl], privateData);
|
||||
}
|
||||
return obj;
|
||||
},
|
||||
interface: ErrorEvent,
|
||||
expose: {
|
||||
Window: { ErrorEvent },
|
||||
Worker: { ErrorEvent }
|
||||
wrapper[implSymbol][utils.wrapperSymbol] = wrapper;
|
||||
if (Impl.init) {
|
||||
Impl.init(wrapper[implSymbol]);
|
||||
}
|
||||
}; // iface
|
||||
module.exports = iface;
|
||||
return wrapper;
|
||||
};
|
||||
|
||||
exports.new = globalObject => {
|
||||
const wrapper = makeWrapper(globalObject);
|
||||
|
||||
exports._internalSetup(wrapper, globalObject);
|
||||
Object.defineProperty(wrapper, implSymbol, {
|
||||
value: Object.create(Impl.implementation.prototype),
|
||||
configurable: true
|
||||
});
|
||||
|
||||
wrapper[implSymbol][utils.wrapperSymbol] = wrapper;
|
||||
if (Impl.init) {
|
||||
Impl.init(wrapper[implSymbol]);
|
||||
}
|
||||
return wrapper[implSymbol];
|
||||
};
|
||||
|
||||
const exposed = new Set(["Window", "Worker"]);
|
||||
|
||||
exports.install = (globalObject, globalNames) => {
|
||||
if (!globalNames.some(globalName => exposed.has(globalName))) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (globalObject.Event === undefined) {
|
||||
throw new Error("Internal error: attempting to evaluate ErrorEvent before Event");
|
||||
}
|
||||
class ErrorEvent extends globalObject.Event {
|
||||
constructor(type) {
|
||||
if (arguments.length < 1) {
|
||||
throw new TypeError(
|
||||
"Failed to construct 'ErrorEvent': 1 argument required, but only " + arguments.length + " present."
|
||||
);
|
||||
}
|
||||
const args = [];
|
||||
{
|
||||
let curArg = arguments[0];
|
||||
curArg = conversions["DOMString"](curArg, { context: "Failed to construct 'ErrorEvent': parameter 1" });
|
||||
args.push(curArg);
|
||||
}
|
||||
{
|
||||
let curArg = arguments[1];
|
||||
curArg = ErrorEventInit.convert(curArg, { context: "Failed to construct 'ErrorEvent': parameter 2" });
|
||||
args.push(curArg);
|
||||
}
|
||||
return exports.setup(Object.create(new.target.prototype), globalObject, args);
|
||||
}
|
||||
|
||||
get message() {
|
||||
const esValue = this !== null && this !== undefined ? this : globalObject;
|
||||
|
||||
if (!exports.is(esValue)) {
|
||||
throw new TypeError("Illegal invocation");
|
||||
}
|
||||
|
||||
return esValue[implSymbol]["message"];
|
||||
}
|
||||
|
||||
get filename() {
|
||||
const esValue = this !== null && this !== undefined ? this : globalObject;
|
||||
|
||||
if (!exports.is(esValue)) {
|
||||
throw new TypeError("Illegal invocation");
|
||||
}
|
||||
|
||||
return esValue[implSymbol]["filename"];
|
||||
}
|
||||
|
||||
get lineno() {
|
||||
const esValue = this !== null && this !== undefined ? this : globalObject;
|
||||
|
||||
if (!exports.is(esValue)) {
|
||||
throw new TypeError("Illegal invocation");
|
||||
}
|
||||
|
||||
return esValue[implSymbol]["lineno"];
|
||||
}
|
||||
|
||||
get colno() {
|
||||
const esValue = this !== null && this !== undefined ? this : globalObject;
|
||||
|
||||
if (!exports.is(esValue)) {
|
||||
throw new TypeError("Illegal invocation");
|
||||
}
|
||||
|
||||
return esValue[implSymbol]["colno"];
|
||||
}
|
||||
|
||||
get error() {
|
||||
const esValue = this !== null && this !== undefined ? this : globalObject;
|
||||
|
||||
if (!exports.is(esValue)) {
|
||||
throw new TypeError("Illegal invocation");
|
||||
}
|
||||
|
||||
return esValue[implSymbol]["error"];
|
||||
}
|
||||
}
|
||||
Object.defineProperties(ErrorEvent.prototype, {
|
||||
message: { enumerable: true },
|
||||
filename: { enumerable: true },
|
||||
lineno: { enumerable: true },
|
||||
colno: { enumerable: true },
|
||||
error: { enumerable: true },
|
||||
[Symbol.toStringTag]: { value: "ErrorEvent", configurable: true }
|
||||
});
|
||||
if (globalObject[ctorRegistrySymbol] === undefined) {
|
||||
globalObject[ctorRegistrySymbol] = Object.create(null);
|
||||
}
|
||||
globalObject[ctorRegistrySymbol][interfaceName] = ErrorEvent;
|
||||
|
||||
Object.defineProperty(globalObject, interfaceName, {
|
||||
configurable: true,
|
||||
writable: true,
|
||||
value: ErrorEvent
|
||||
});
|
||||
};
|
||||
|
||||
const Impl = require("../events/ErrorEvent-impl.js");
|
||||
|
||||
114
node_modules/jsdom/lib/jsdom/living/generated/ErrorEventInit.js
generated
vendored
114
node_modules/jsdom/lib/jsdom/living/generated/ErrorEventInit.js
generated
vendored
@@ -5,78 +5,76 @@ const utils = require("./utils.js");
|
||||
|
||||
const EventInit = require("./EventInit.js");
|
||||
|
||||
module.exports = {
|
||||
convertInherit(obj, ret, { context = "The provided value" } = {}) {
|
||||
EventInit.convertInherit(obj, ret, { context });
|
||||
exports._convertInherit = (obj, ret, { context = "The provided value" } = {}) => {
|
||||
EventInit._convertInherit(obj, ret, { context });
|
||||
|
||||
{
|
||||
const key = "colno";
|
||||
let value = obj === undefined || obj === null ? undefined : obj[key];
|
||||
if (value !== undefined) {
|
||||
value = conversions["unsigned long"](value, { context: context + " has member colno that" });
|
||||
{
|
||||
const key = "colno";
|
||||
let value = obj === undefined || obj === null ? undefined : obj[key];
|
||||
if (value !== undefined) {
|
||||
value = conversions["unsigned long"](value, { context: context + " has member 'colno' that" });
|
||||
|
||||
ret[key] = value;
|
||||
} else {
|
||||
ret[key] = 0;
|
||||
}
|
||||
ret[key] = value;
|
||||
} else {
|
||||
ret[key] = 0;
|
||||
}
|
||||
}
|
||||
|
||||
{
|
||||
const key = "error";
|
||||
let value = obj === undefined || obj === null ? undefined : obj[key];
|
||||
if (value !== undefined) {
|
||||
value = conversions["any"](value, { context: context + " has member error that" });
|
||||
{
|
||||
const key = "error";
|
||||
let value = obj === undefined || obj === null ? undefined : obj[key];
|
||||
if (value !== undefined) {
|
||||
value = conversions["any"](value, { context: context + " has member 'error' that" });
|
||||
|
||||
ret[key] = value;
|
||||
} else {
|
||||
ret[key] = null;
|
||||
}
|
||||
ret[key] = value;
|
||||
} else {
|
||||
ret[key] = null;
|
||||
}
|
||||
}
|
||||
|
||||
{
|
||||
const key = "filename";
|
||||
let value = obj === undefined || obj === null ? undefined : obj[key];
|
||||
if (value !== undefined) {
|
||||
value = conversions["USVString"](value, { context: context + " has member filename that" });
|
||||
{
|
||||
const key = "filename";
|
||||
let value = obj === undefined || obj === null ? undefined : obj[key];
|
||||
if (value !== undefined) {
|
||||
value = conversions["USVString"](value, { context: context + " has member 'filename' that" });
|
||||
|
||||
ret[key] = value;
|
||||
} else {
|
||||
ret[key] = "";
|
||||
}
|
||||
ret[key] = value;
|
||||
} else {
|
||||
ret[key] = "";
|
||||
}
|
||||
}
|
||||
|
||||
{
|
||||
const key = "lineno";
|
||||
let value = obj === undefined || obj === null ? undefined : obj[key];
|
||||
if (value !== undefined) {
|
||||
value = conversions["unsigned long"](value, { context: context + " has member lineno that" });
|
||||
{
|
||||
const key = "lineno";
|
||||
let value = obj === undefined || obj === null ? undefined : obj[key];
|
||||
if (value !== undefined) {
|
||||
value = conversions["unsigned long"](value, { context: context + " has member 'lineno' that" });
|
||||
|
||||
ret[key] = value;
|
||||
} else {
|
||||
ret[key] = 0;
|
||||
}
|
||||
ret[key] = value;
|
||||
} else {
|
||||
ret[key] = 0;
|
||||
}
|
||||
}
|
||||
|
||||
{
|
||||
const key = "message";
|
||||
let value = obj === undefined || obj === null ? undefined : obj[key];
|
||||
if (value !== undefined) {
|
||||
value = conversions["DOMString"](value, { context: context + " has member message that" });
|
||||
{
|
||||
const key = "message";
|
||||
let value = obj === undefined || obj === null ? undefined : obj[key];
|
||||
if (value !== undefined) {
|
||||
value = conversions["DOMString"](value, { context: context + " has member 'message' that" });
|
||||
|
||||
ret[key] = value;
|
||||
} else {
|
||||
ret[key] = "";
|
||||
}
|
||||
ret[key] = value;
|
||||
} else {
|
||||
ret[key] = "";
|
||||
}
|
||||
},
|
||||
|
||||
convert(obj, { context = "The provided value" } = {}) {
|
||||
if (obj !== undefined && typeof obj !== "object" && typeof obj !== "function") {
|
||||
throw new TypeError(`${context} is not an object.`);
|
||||
}
|
||||
|
||||
const ret = Object.create(null);
|
||||
module.exports.convertInherit(obj, ret, { context });
|
||||
return ret;
|
||||
}
|
||||
};
|
||||
|
||||
exports.convert = function convert(obj, { context = "The provided value" } = {}) {
|
||||
if (obj !== undefined && typeof obj !== "object" && typeof obj !== "function") {
|
||||
throw new TypeError(`${context} is not an object.`);
|
||||
}
|
||||
|
||||
const ret = Object.create(null);
|
||||
exports._convertInherit(obj, ret, { context });
|
||||
return ret;
|
||||
};
|
||||
|
||||
741
node_modules/jsdom/lib/jsdom/living/generated/Event.js
generated
vendored
741
node_modules/jsdom/lib/jsdom/living/generated/Event.js
generated
vendored
@@ -3,403 +3,388 @@
|
||||
const conversions = require("webidl-conversions");
|
||||
const utils = require("./utils.js");
|
||||
|
||||
const convertEventInit = require("./EventInit.js").convert;
|
||||
const impl = utils.implSymbol;
|
||||
const EventInit = require("./EventInit.js");
|
||||
const implSymbol = utils.implSymbol;
|
||||
const ctorRegistrySymbol = utils.ctorRegistrySymbol;
|
||||
|
||||
function Event(type) {
|
||||
if (new.target === undefined) {
|
||||
throw new TypeError(
|
||||
"Failed to construct 'Event'. Please use the 'new' operator; this constructor " +
|
||||
"cannot be called as a function."
|
||||
);
|
||||
const interfaceName = "Event";
|
||||
|
||||
exports.is = value => {
|
||||
return utils.isObject(value) && utils.hasOwn(value, implSymbol) && value[implSymbol] instanceof Impl.implementation;
|
||||
};
|
||||
exports.isImpl = value => {
|
||||
return utils.isObject(value) && value instanceof Impl.implementation;
|
||||
};
|
||||
exports.convert = (value, { context = "The provided value" } = {}) => {
|
||||
if (exports.is(value)) {
|
||||
return utils.implForWrapper(value);
|
||||
}
|
||||
throw new TypeError(`${context} is not of type 'Event'.`);
|
||||
};
|
||||
|
||||
function makeWrapper(globalObject) {
|
||||
if (globalObject[ctorRegistrySymbol] === undefined) {
|
||||
throw new Error("Internal error: invalid global object");
|
||||
}
|
||||
|
||||
if (arguments.length < 1) {
|
||||
throw new TypeError("Failed to construct 'Event': 1 argument required, but only " + arguments.length + " present.");
|
||||
}
|
||||
const args = [];
|
||||
{
|
||||
let curArg = arguments[0];
|
||||
curArg = conversions["DOMString"](curArg, { context: "Failed to construct 'Event': parameter 1" });
|
||||
args.push(curArg);
|
||||
}
|
||||
{
|
||||
let curArg = arguments[1];
|
||||
curArg = convertEventInit(curArg, { context: "Failed to construct 'Event': parameter 2" });
|
||||
args.push(curArg);
|
||||
const ctor = globalObject[ctorRegistrySymbol]["Event"];
|
||||
if (ctor === undefined) {
|
||||
throw new Error("Internal error: constructor Event is not installed on the passed global object");
|
||||
}
|
||||
|
||||
iface.setup(this, args);
|
||||
return Object.create(ctor.prototype);
|
||||
}
|
||||
|
||||
Object.defineProperty(Event, "prototype", {
|
||||
value: Event.prototype,
|
||||
writable: false,
|
||||
enumerable: false,
|
||||
configurable: false
|
||||
});
|
||||
|
||||
Event.prototype.stopPropagation = function stopPropagation() {
|
||||
if (!this || !module.exports.is(this)) {
|
||||
throw new TypeError("Illegal invocation");
|
||||
}
|
||||
|
||||
return this[impl].stopPropagation();
|
||||
exports.create = (globalObject, constructorArgs, privateData) => {
|
||||
const wrapper = makeWrapper(globalObject);
|
||||
return exports.setup(wrapper, globalObject, constructorArgs, privateData);
|
||||
};
|
||||
|
||||
Event.prototype.stopImmediatePropagation = function stopImmediatePropagation() {
|
||||
if (!this || !module.exports.is(this)) {
|
||||
throw new TypeError("Illegal invocation");
|
||||
}
|
||||
|
||||
return this[impl].stopImmediatePropagation();
|
||||
exports.createImpl = (globalObject, constructorArgs, privateData) => {
|
||||
const wrapper = exports.create(globalObject, constructorArgs, privateData);
|
||||
return utils.implForWrapper(wrapper);
|
||||
};
|
||||
|
||||
Event.prototype.preventDefault = function preventDefault() {
|
||||
if (!this || !module.exports.is(this)) {
|
||||
throw new TypeError("Illegal invocation");
|
||||
}
|
||||
exports._internalSetup = (wrapper, globalObject) => {
|
||||
Object.defineProperties(
|
||||
wrapper,
|
||||
Object.getOwnPropertyDescriptors({
|
||||
get isTrusted() {
|
||||
const esValue = this !== null && this !== undefined ? this : globalObject;
|
||||
|
||||
return this[impl].preventDefault();
|
||||
};
|
||||
|
||||
Event.prototype.initEvent = function initEvent(type) {
|
||||
if (!this || !module.exports.is(this)) {
|
||||
throw new TypeError("Illegal invocation");
|
||||
}
|
||||
|
||||
if (arguments.length < 1) {
|
||||
throw new TypeError(
|
||||
"Failed to execute 'initEvent' on 'Event': 1 argument required, but only " + arguments.length + " present."
|
||||
);
|
||||
}
|
||||
const args = [];
|
||||
{
|
||||
let curArg = arguments[0];
|
||||
curArg = conversions["DOMString"](curArg, { context: "Failed to execute 'initEvent' on 'Event': parameter 1" });
|
||||
args.push(curArg);
|
||||
}
|
||||
{
|
||||
let curArg = arguments[1];
|
||||
if (curArg !== undefined) {
|
||||
curArg = conversions["boolean"](curArg, { context: "Failed to execute 'initEvent' on 'Event': parameter 2" });
|
||||
} else {
|
||||
curArg = false;
|
||||
}
|
||||
args.push(curArg);
|
||||
}
|
||||
{
|
||||
let curArg = arguments[2];
|
||||
if (curArg !== undefined) {
|
||||
curArg = conversions["boolean"](curArg, { context: "Failed to execute 'initEvent' on 'Event': parameter 3" });
|
||||
} else {
|
||||
curArg = false;
|
||||
}
|
||||
args.push(curArg);
|
||||
}
|
||||
return this[impl].initEvent(...args);
|
||||
};
|
||||
|
||||
Object.defineProperty(Event.prototype, "type", {
|
||||
get() {
|
||||
if (!this || !module.exports.is(this)) {
|
||||
throw new TypeError("Illegal invocation");
|
||||
}
|
||||
|
||||
return this[impl]["type"];
|
||||
},
|
||||
|
||||
enumerable: true,
|
||||
configurable: true
|
||||
});
|
||||
|
||||
Object.defineProperty(Event.prototype, "target", {
|
||||
get() {
|
||||
if (!this || !module.exports.is(this)) {
|
||||
throw new TypeError("Illegal invocation");
|
||||
}
|
||||
|
||||
return utils.tryWrapperForImpl(this[impl]["target"]);
|
||||
},
|
||||
|
||||
enumerable: true,
|
||||
configurable: true
|
||||
});
|
||||
|
||||
Object.defineProperty(Event.prototype, "srcElement", {
|
||||
get() {
|
||||
if (!this || !module.exports.is(this)) {
|
||||
throw new TypeError("Illegal invocation");
|
||||
}
|
||||
|
||||
return utils.tryWrapperForImpl(this[impl]["srcElement"]);
|
||||
},
|
||||
|
||||
enumerable: true,
|
||||
configurable: true
|
||||
});
|
||||
|
||||
Object.defineProperty(Event.prototype, "currentTarget", {
|
||||
get() {
|
||||
if (!this || !module.exports.is(this)) {
|
||||
throw new TypeError("Illegal invocation");
|
||||
}
|
||||
|
||||
return utils.tryWrapperForImpl(this[impl]["currentTarget"]);
|
||||
},
|
||||
|
||||
enumerable: true,
|
||||
configurable: true
|
||||
});
|
||||
|
||||
Object.defineProperty(Event.prototype, "eventPhase", {
|
||||
get() {
|
||||
if (!this || !module.exports.is(this)) {
|
||||
throw new TypeError("Illegal invocation");
|
||||
}
|
||||
|
||||
return this[impl]["eventPhase"];
|
||||
},
|
||||
|
||||
enumerable: true,
|
||||
configurable: true
|
||||
});
|
||||
|
||||
Object.defineProperty(Event.prototype, "cancelBubble", {
|
||||
get() {
|
||||
if (!this || !module.exports.is(this)) {
|
||||
throw new TypeError("Illegal invocation");
|
||||
}
|
||||
|
||||
return this[impl]["cancelBubble"];
|
||||
},
|
||||
|
||||
set(V) {
|
||||
if (!this || !module.exports.is(this)) {
|
||||
throw new TypeError("Illegal invocation");
|
||||
}
|
||||
|
||||
V = conversions["boolean"](V, {
|
||||
context: "Failed to set the 'cancelBubble' property on 'Event': The provided value"
|
||||
});
|
||||
|
||||
this[impl]["cancelBubble"] = V;
|
||||
},
|
||||
|
||||
enumerable: true,
|
||||
configurable: true
|
||||
});
|
||||
|
||||
Object.defineProperty(Event.prototype, "bubbles", {
|
||||
get() {
|
||||
if (!this || !module.exports.is(this)) {
|
||||
throw new TypeError("Illegal invocation");
|
||||
}
|
||||
|
||||
return this[impl]["bubbles"];
|
||||
},
|
||||
|
||||
enumerable: true,
|
||||
configurable: true
|
||||
});
|
||||
|
||||
Object.defineProperty(Event.prototype, "cancelable", {
|
||||
get() {
|
||||
if (!this || !module.exports.is(this)) {
|
||||
throw new TypeError("Illegal invocation");
|
||||
}
|
||||
|
||||
return this[impl]["cancelable"];
|
||||
},
|
||||
|
||||
enumerable: true,
|
||||
configurable: true
|
||||
});
|
||||
|
||||
Object.defineProperty(Event.prototype, "returnValue", {
|
||||
get() {
|
||||
if (!this || !module.exports.is(this)) {
|
||||
throw new TypeError("Illegal invocation");
|
||||
}
|
||||
|
||||
return this[impl]["returnValue"];
|
||||
},
|
||||
|
||||
set(V) {
|
||||
if (!this || !module.exports.is(this)) {
|
||||
throw new TypeError("Illegal invocation");
|
||||
}
|
||||
|
||||
V = conversions["boolean"](V, {
|
||||
context: "Failed to set the 'returnValue' property on 'Event': The provided value"
|
||||
});
|
||||
|
||||
this[impl]["returnValue"] = V;
|
||||
},
|
||||
|
||||
enumerable: true,
|
||||
configurable: true
|
||||
});
|
||||
|
||||
Object.defineProperty(Event.prototype, "defaultPrevented", {
|
||||
get() {
|
||||
if (!this || !module.exports.is(this)) {
|
||||
throw new TypeError("Illegal invocation");
|
||||
}
|
||||
|
||||
return this[impl]["defaultPrevented"];
|
||||
},
|
||||
|
||||
enumerable: true,
|
||||
configurable: true
|
||||
});
|
||||
|
||||
Object.defineProperty(Event.prototype, "timeStamp", {
|
||||
get() {
|
||||
if (!this || !module.exports.is(this)) {
|
||||
throw new TypeError("Illegal invocation");
|
||||
}
|
||||
|
||||
return this[impl]["timeStamp"];
|
||||
},
|
||||
|
||||
enumerable: true,
|
||||
configurable: true
|
||||
});
|
||||
|
||||
Object.defineProperty(Event, "NONE", {
|
||||
value: 0,
|
||||
enumerable: true
|
||||
});
|
||||
Object.defineProperty(Event.prototype, "NONE", {
|
||||
value: 0,
|
||||
enumerable: true
|
||||
});
|
||||
|
||||
Object.defineProperty(Event, "CAPTURING_PHASE", {
|
||||
value: 1,
|
||||
enumerable: true
|
||||
});
|
||||
Object.defineProperty(Event.prototype, "CAPTURING_PHASE", {
|
||||
value: 1,
|
||||
enumerable: true
|
||||
});
|
||||
|
||||
Object.defineProperty(Event, "AT_TARGET", {
|
||||
value: 2,
|
||||
enumerable: true
|
||||
});
|
||||
Object.defineProperty(Event.prototype, "AT_TARGET", {
|
||||
value: 2,
|
||||
enumerable: true
|
||||
});
|
||||
|
||||
Object.defineProperty(Event, "BUBBLING_PHASE", {
|
||||
value: 3,
|
||||
enumerable: true
|
||||
});
|
||||
Object.defineProperty(Event.prototype, "BUBBLING_PHASE", {
|
||||
value: 3,
|
||||
enumerable: true
|
||||
});
|
||||
|
||||
Object.defineProperty(Event.prototype, Symbol.toStringTag, {
|
||||
value: "Event",
|
||||
writable: false,
|
||||
enumerable: false,
|
||||
configurable: true
|
||||
});
|
||||
|
||||
const iface = {
|
||||
// When an interface-module that implements this interface as a mixin is loaded, it will append its own `.is()`
|
||||
// method into this array. It allows objects that directly implements *those* interfaces to be recognized as
|
||||
// implementing this mixin interface.
|
||||
_mixedIntoPredicates: [],
|
||||
is(obj) {
|
||||
if (obj) {
|
||||
if (utils.hasOwn(obj, impl) && obj[impl] instanceof Impl.implementation) {
|
||||
return true;
|
||||
}
|
||||
for (const isMixedInto of module.exports._mixedIntoPredicates) {
|
||||
if (isMixedInto(obj)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
},
|
||||
isImpl(obj) {
|
||||
if (obj) {
|
||||
if (obj instanceof Impl.implementation) {
|
||||
return true;
|
||||
}
|
||||
|
||||
const wrapper = utils.wrapperForImpl(obj);
|
||||
for (const isMixedInto of module.exports._mixedIntoPredicates) {
|
||||
if (isMixedInto(wrapper)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
},
|
||||
convert(obj, { context = "The provided value" } = {}) {
|
||||
if (module.exports.is(obj)) {
|
||||
return utils.implForWrapper(obj);
|
||||
}
|
||||
throw new TypeError(`${context} is not of type 'Event'.`);
|
||||
},
|
||||
|
||||
create(constructorArgs, privateData) {
|
||||
let obj = Object.create(Event.prototype);
|
||||
obj = this.setup(obj, constructorArgs, privateData);
|
||||
return obj;
|
||||
},
|
||||
createImpl(constructorArgs, privateData) {
|
||||
let obj = Object.create(Event.prototype);
|
||||
obj = this.setup(obj, constructorArgs, privateData);
|
||||
return utils.implForWrapper(obj);
|
||||
},
|
||||
_internalSetup(obj) {
|
||||
Object.defineProperty(obj, "isTrusted", {
|
||||
get() {
|
||||
if (!this || !module.exports.is(this)) {
|
||||
if (!exports.is(esValue)) {
|
||||
throw new TypeError("Illegal invocation");
|
||||
}
|
||||
|
||||
return obj[impl]["isTrusted"];
|
||||
},
|
||||
return esValue[implSymbol]["isTrusted"];
|
||||
}
|
||||
})
|
||||
);
|
||||
|
||||
enumerable: true,
|
||||
configurable: false
|
||||
});
|
||||
},
|
||||
setup(obj, constructorArgs, privateData) {
|
||||
if (!privateData) privateData = {};
|
||||
Object.defineProperties(wrapper, { isTrusted: { configurable: false } });
|
||||
};
|
||||
|
||||
privateData.wrapper = obj;
|
||||
exports.setup = (wrapper, globalObject, constructorArgs = [], privateData = {}) => {
|
||||
privateData.wrapper = wrapper;
|
||||
|
||||
this._internalSetup(obj);
|
||||
Object.defineProperty(obj, impl, {
|
||||
value: new Impl.implementation(constructorArgs, privateData),
|
||||
writable: false,
|
||||
enumerable: false,
|
||||
configurable: true
|
||||
});
|
||||
exports._internalSetup(wrapper, globalObject);
|
||||
Object.defineProperty(wrapper, implSymbol, {
|
||||
value: new Impl.implementation(globalObject, constructorArgs, privateData),
|
||||
configurable: true
|
||||
});
|
||||
|
||||
obj[impl][utils.wrapperSymbol] = obj;
|
||||
if (Impl.init) {
|
||||
Impl.init(obj[impl], privateData);
|
||||
}
|
||||
return obj;
|
||||
},
|
||||
interface: Event,
|
||||
expose: {
|
||||
Window: { Event },
|
||||
Worker: { Event },
|
||||
AudioWorklet: { Event }
|
||||
wrapper[implSymbol][utils.wrapperSymbol] = wrapper;
|
||||
if (Impl.init) {
|
||||
Impl.init(wrapper[implSymbol]);
|
||||
}
|
||||
}; // iface
|
||||
module.exports = iface;
|
||||
return wrapper;
|
||||
};
|
||||
|
||||
exports.new = globalObject => {
|
||||
const wrapper = makeWrapper(globalObject);
|
||||
|
||||
exports._internalSetup(wrapper, globalObject);
|
||||
Object.defineProperty(wrapper, implSymbol, {
|
||||
value: Object.create(Impl.implementation.prototype),
|
||||
configurable: true
|
||||
});
|
||||
|
||||
wrapper[implSymbol][utils.wrapperSymbol] = wrapper;
|
||||
if (Impl.init) {
|
||||
Impl.init(wrapper[implSymbol]);
|
||||
}
|
||||
return wrapper[implSymbol];
|
||||
};
|
||||
|
||||
const exposed = new Set(["Window", "Worker", "AudioWorklet"]);
|
||||
|
||||
exports.install = (globalObject, globalNames) => {
|
||||
if (!globalNames.some(globalName => exposed.has(globalName))) {
|
||||
return;
|
||||
}
|
||||
class Event {
|
||||
constructor(type) {
|
||||
if (arguments.length < 1) {
|
||||
throw new TypeError(
|
||||
"Failed to construct 'Event': 1 argument required, but only " + arguments.length + " present."
|
||||
);
|
||||
}
|
||||
const args = [];
|
||||
{
|
||||
let curArg = arguments[0];
|
||||
curArg = conversions["DOMString"](curArg, { context: "Failed to construct 'Event': parameter 1" });
|
||||
args.push(curArg);
|
||||
}
|
||||
{
|
||||
let curArg = arguments[1];
|
||||
curArg = EventInit.convert(curArg, { context: "Failed to construct 'Event': parameter 2" });
|
||||
args.push(curArg);
|
||||
}
|
||||
return exports.setup(Object.create(new.target.prototype), globalObject, args);
|
||||
}
|
||||
|
||||
composedPath() {
|
||||
const esValue = this !== null && this !== undefined ? this : globalObject;
|
||||
if (!exports.is(esValue)) {
|
||||
throw new TypeError("Illegal invocation");
|
||||
}
|
||||
|
||||
return utils.tryWrapperForImpl(esValue[implSymbol].composedPath());
|
||||
}
|
||||
|
||||
stopPropagation() {
|
||||
const esValue = this !== null && this !== undefined ? this : globalObject;
|
||||
if (!exports.is(esValue)) {
|
||||
throw new TypeError("Illegal invocation");
|
||||
}
|
||||
|
||||
return esValue[implSymbol].stopPropagation();
|
||||
}
|
||||
|
||||
stopImmediatePropagation() {
|
||||
const esValue = this !== null && this !== undefined ? this : globalObject;
|
||||
if (!exports.is(esValue)) {
|
||||
throw new TypeError("Illegal invocation");
|
||||
}
|
||||
|
||||
return esValue[implSymbol].stopImmediatePropagation();
|
||||
}
|
||||
|
||||
preventDefault() {
|
||||
const esValue = this !== null && this !== undefined ? this : globalObject;
|
||||
if (!exports.is(esValue)) {
|
||||
throw new TypeError("Illegal invocation");
|
||||
}
|
||||
|
||||
return esValue[implSymbol].preventDefault();
|
||||
}
|
||||
|
||||
initEvent(type) {
|
||||
const esValue = this !== null && this !== undefined ? this : globalObject;
|
||||
if (!exports.is(esValue)) {
|
||||
throw new TypeError("Illegal invocation");
|
||||
}
|
||||
|
||||
if (arguments.length < 1) {
|
||||
throw new TypeError(
|
||||
"Failed to execute 'initEvent' on 'Event': 1 argument required, but only " + arguments.length + " present."
|
||||
);
|
||||
}
|
||||
const args = [];
|
||||
{
|
||||
let curArg = arguments[0];
|
||||
curArg = conversions["DOMString"](curArg, { context: "Failed to execute 'initEvent' on 'Event': parameter 1" });
|
||||
args.push(curArg);
|
||||
}
|
||||
{
|
||||
let curArg = arguments[1];
|
||||
if (curArg !== undefined) {
|
||||
curArg = conversions["boolean"](curArg, { context: "Failed to execute 'initEvent' on 'Event': parameter 2" });
|
||||
} else {
|
||||
curArg = false;
|
||||
}
|
||||
args.push(curArg);
|
||||
}
|
||||
{
|
||||
let curArg = arguments[2];
|
||||
if (curArg !== undefined) {
|
||||
curArg = conversions["boolean"](curArg, { context: "Failed to execute 'initEvent' on 'Event': parameter 3" });
|
||||
} else {
|
||||
curArg = false;
|
||||
}
|
||||
args.push(curArg);
|
||||
}
|
||||
return esValue[implSymbol].initEvent(...args);
|
||||
}
|
||||
|
||||
get type() {
|
||||
const esValue = this !== null && this !== undefined ? this : globalObject;
|
||||
|
||||
if (!exports.is(esValue)) {
|
||||
throw new TypeError("Illegal invocation");
|
||||
}
|
||||
|
||||
return esValue[implSymbol]["type"];
|
||||
}
|
||||
|
||||
get target() {
|
||||
const esValue = this !== null && this !== undefined ? this : globalObject;
|
||||
|
||||
if (!exports.is(esValue)) {
|
||||
throw new TypeError("Illegal invocation");
|
||||
}
|
||||
|
||||
return utils.tryWrapperForImpl(esValue[implSymbol]["target"]);
|
||||
}
|
||||
|
||||
get srcElement() {
|
||||
const esValue = this !== null && this !== undefined ? this : globalObject;
|
||||
|
||||
if (!exports.is(esValue)) {
|
||||
throw new TypeError("Illegal invocation");
|
||||
}
|
||||
|
||||
return utils.tryWrapperForImpl(esValue[implSymbol]["srcElement"]);
|
||||
}
|
||||
|
||||
get currentTarget() {
|
||||
const esValue = this !== null && this !== undefined ? this : globalObject;
|
||||
|
||||
if (!exports.is(esValue)) {
|
||||
throw new TypeError("Illegal invocation");
|
||||
}
|
||||
|
||||
return utils.tryWrapperForImpl(esValue[implSymbol]["currentTarget"]);
|
||||
}
|
||||
|
||||
get eventPhase() {
|
||||
const esValue = this !== null && this !== undefined ? this : globalObject;
|
||||
|
||||
if (!exports.is(esValue)) {
|
||||
throw new TypeError("Illegal invocation");
|
||||
}
|
||||
|
||||
return esValue[implSymbol]["eventPhase"];
|
||||
}
|
||||
|
||||
get cancelBubble() {
|
||||
const esValue = this !== null && this !== undefined ? this : globalObject;
|
||||
|
||||
if (!exports.is(esValue)) {
|
||||
throw new TypeError("Illegal invocation");
|
||||
}
|
||||
|
||||
return esValue[implSymbol]["cancelBubble"];
|
||||
}
|
||||
|
||||
set cancelBubble(V) {
|
||||
const esValue = this !== null && this !== undefined ? this : globalObject;
|
||||
|
||||
if (!exports.is(esValue)) {
|
||||
throw new TypeError("Illegal invocation");
|
||||
}
|
||||
|
||||
V = conversions["boolean"](V, {
|
||||
context: "Failed to set the 'cancelBubble' property on 'Event': The provided value"
|
||||
});
|
||||
|
||||
esValue[implSymbol]["cancelBubble"] = V;
|
||||
}
|
||||
|
||||
get bubbles() {
|
||||
const esValue = this !== null && this !== undefined ? this : globalObject;
|
||||
|
||||
if (!exports.is(esValue)) {
|
||||
throw new TypeError("Illegal invocation");
|
||||
}
|
||||
|
||||
return esValue[implSymbol]["bubbles"];
|
||||
}
|
||||
|
||||
get cancelable() {
|
||||
const esValue = this !== null && this !== undefined ? this : globalObject;
|
||||
|
||||
if (!exports.is(esValue)) {
|
||||
throw new TypeError("Illegal invocation");
|
||||
}
|
||||
|
||||
return esValue[implSymbol]["cancelable"];
|
||||
}
|
||||
|
||||
get returnValue() {
|
||||
const esValue = this !== null && this !== undefined ? this : globalObject;
|
||||
|
||||
if (!exports.is(esValue)) {
|
||||
throw new TypeError("Illegal invocation");
|
||||
}
|
||||
|
||||
return esValue[implSymbol]["returnValue"];
|
||||
}
|
||||
|
||||
set returnValue(V) {
|
||||
const esValue = this !== null && this !== undefined ? this : globalObject;
|
||||
|
||||
if (!exports.is(esValue)) {
|
||||
throw new TypeError("Illegal invocation");
|
||||
}
|
||||
|
||||
V = conversions["boolean"](V, {
|
||||
context: "Failed to set the 'returnValue' property on 'Event': The provided value"
|
||||
});
|
||||
|
||||
esValue[implSymbol]["returnValue"] = V;
|
||||
}
|
||||
|
||||
get defaultPrevented() {
|
||||
const esValue = this !== null && this !== undefined ? this : globalObject;
|
||||
|
||||
if (!exports.is(esValue)) {
|
||||
throw new TypeError("Illegal invocation");
|
||||
}
|
||||
|
||||
return esValue[implSymbol]["defaultPrevented"];
|
||||
}
|
||||
|
||||
get composed() {
|
||||
const esValue = this !== null && this !== undefined ? this : globalObject;
|
||||
|
||||
if (!exports.is(esValue)) {
|
||||
throw new TypeError("Illegal invocation");
|
||||
}
|
||||
|
||||
return esValue[implSymbol]["composed"];
|
||||
}
|
||||
|
||||
get timeStamp() {
|
||||
const esValue = this !== null && this !== undefined ? this : globalObject;
|
||||
|
||||
if (!exports.is(esValue)) {
|
||||
throw new TypeError("Illegal invocation");
|
||||
}
|
||||
|
||||
return esValue[implSymbol]["timeStamp"];
|
||||
}
|
||||
}
|
||||
Object.defineProperties(Event.prototype, {
|
||||
composedPath: { enumerable: true },
|
||||
stopPropagation: { enumerable: true },
|
||||
stopImmediatePropagation: { enumerable: true },
|
||||
preventDefault: { enumerable: true },
|
||||
initEvent: { enumerable: true },
|
||||
type: { enumerable: true },
|
||||
target: { enumerable: true },
|
||||
srcElement: { enumerable: true },
|
||||
currentTarget: { enumerable: true },
|
||||
eventPhase: { enumerable: true },
|
||||
cancelBubble: { enumerable: true },
|
||||
bubbles: { enumerable: true },
|
||||
cancelable: { enumerable: true },
|
||||
returnValue: { enumerable: true },
|
||||
defaultPrevented: { enumerable: true },
|
||||
composed: { enumerable: true },
|
||||
timeStamp: { enumerable: true },
|
||||
[Symbol.toStringTag]: { value: "Event", configurable: true },
|
||||
NONE: { value: 0, enumerable: true },
|
||||
CAPTURING_PHASE: { value: 1, enumerable: true },
|
||||
AT_TARGET: { value: 2, enumerable: true },
|
||||
BUBBLING_PHASE: { value: 3, enumerable: true }
|
||||
});
|
||||
Object.defineProperties(Event, {
|
||||
NONE: { value: 0, enumerable: true },
|
||||
CAPTURING_PHASE: { value: 1, enumerable: true },
|
||||
AT_TARGET: { value: 2, enumerable: true },
|
||||
BUBBLING_PHASE: { value: 3, enumerable: true }
|
||||
});
|
||||
if (globalObject[ctorRegistrySymbol] === undefined) {
|
||||
globalObject[ctorRegistrySymbol] = Object.create(null);
|
||||
}
|
||||
globalObject[ctorRegistrySymbol][interfaceName] = Event;
|
||||
|
||||
Object.defineProperty(globalObject, interfaceName, {
|
||||
configurable: true,
|
||||
writable: true,
|
||||
value: Event
|
||||
});
|
||||
};
|
||||
|
||||
const Impl = require("../events/Event-impl.js");
|
||||
|
||||
66
node_modules/jsdom/lib/jsdom/living/generated/EventInit.js
generated
vendored
66
node_modules/jsdom/lib/jsdom/living/generated/EventInit.js
generated
vendored
@@ -3,40 +3,50 @@
|
||||
const conversions = require("webidl-conversions");
|
||||
const utils = require("./utils.js");
|
||||
|
||||
module.exports = {
|
||||
convertInherit(obj, ret, { context = "The provided value" } = {}) {
|
||||
{
|
||||
const key = "bubbles";
|
||||
let value = obj === undefined || obj === null ? undefined : obj[key];
|
||||
if (value !== undefined) {
|
||||
value = conversions["boolean"](value, { context: context + " has member bubbles that" });
|
||||
exports._convertInherit = (obj, ret, { context = "The provided value" } = {}) => {
|
||||
{
|
||||
const key = "bubbles";
|
||||
let value = obj === undefined || obj === null ? undefined : obj[key];
|
||||
if (value !== undefined) {
|
||||
value = conversions["boolean"](value, { context: context + " has member 'bubbles' that" });
|
||||
|
||||
ret[key] = value;
|
||||
} else {
|
||||
ret[key] = false;
|
||||
}
|
||||
ret[key] = value;
|
||||
} else {
|
||||
ret[key] = false;
|
||||
}
|
||||
}
|
||||
|
||||
{
|
||||
const key = "cancelable";
|
||||
let value = obj === undefined || obj === null ? undefined : obj[key];
|
||||
if (value !== undefined) {
|
||||
value = conversions["boolean"](value, { context: context + " has member cancelable that" });
|
||||
{
|
||||
const key = "cancelable";
|
||||
let value = obj === undefined || obj === null ? undefined : obj[key];
|
||||
if (value !== undefined) {
|
||||
value = conversions["boolean"](value, { context: context + " has member 'cancelable' that" });
|
||||
|
||||
ret[key] = value;
|
||||
} else {
|
||||
ret[key] = false;
|
||||
}
|
||||
ret[key] = value;
|
||||
} else {
|
||||
ret[key] = false;
|
||||
}
|
||||
},
|
||||
}
|
||||
|
||||
convert(obj, { context = "The provided value" } = {}) {
|
||||
if (obj !== undefined && typeof obj !== "object" && typeof obj !== "function") {
|
||||
throw new TypeError(`${context} is not an object.`);
|
||||
{
|
||||
const key = "composed";
|
||||
let value = obj === undefined || obj === null ? undefined : obj[key];
|
||||
if (value !== undefined) {
|
||||
value = conversions["boolean"](value, { context: context + " has member 'composed' that" });
|
||||
|
||||
ret[key] = value;
|
||||
} else {
|
||||
ret[key] = false;
|
||||
}
|
||||
|
||||
const ret = Object.create(null);
|
||||
module.exports.convertInherit(obj, ret, { context });
|
||||
return ret;
|
||||
}
|
||||
};
|
||||
|
||||
exports.convert = function convert(obj, { context = "The provided value" } = {}) {
|
||||
if (obj !== undefined && typeof obj !== "object" && typeof obj !== "function") {
|
||||
throw new TypeError(`${context} is not an object.`);
|
||||
}
|
||||
|
||||
const ret = Object.create(null);
|
||||
exports._convertInherit(obj, ret, { context });
|
||||
return ret;
|
||||
};
|
||||
|
||||
35
node_modules/jsdom/lib/jsdom/living/generated/EventListener.js
generated
vendored
Normal file
35
node_modules/jsdom/lib/jsdom/living/generated/EventListener.js
generated
vendored
Normal file
@@ -0,0 +1,35 @@
|
||||
"use strict";
|
||||
|
||||
const conversions = require("webidl-conversions");
|
||||
const utils = require("./utils.js");
|
||||
|
||||
exports.convert = function convert(value, { context = "The provided value" } = {}) {
|
||||
if (!utils.isObject(value)) {
|
||||
throw new TypeError(`${context} is not an object.`);
|
||||
}
|
||||
|
||||
function callTheUserObjectsOperation(event) {
|
||||
let thisArg = utils.tryWrapperForImpl(this);
|
||||
let O = value;
|
||||
let X = O;
|
||||
|
||||
if (typeof O !== "function") {
|
||||
X = O["handleEvent"];
|
||||
if (typeof X !== "function") {
|
||||
throw new TypeError(`${context} does not correctly implement EventListener.`);
|
||||
}
|
||||
thisArg = O;
|
||||
}
|
||||
|
||||
event = utils.tryWrapperForImpl(event);
|
||||
|
||||
let callResult = Reflect.apply(X, thisArg, [event]);
|
||||
}
|
||||
|
||||
callTheUserObjectsOperation[utils.wrapperSymbol] = value;
|
||||
callTheUserObjectsOperation.objectReference = value;
|
||||
|
||||
return callTheUserObjectsOperation;
|
||||
};
|
||||
|
||||
exports.install = (globalObject, globalNames) => {};
|
||||
40
node_modules/jsdom/lib/jsdom/living/generated/EventListenerOptions.js
generated
vendored
40
node_modules/jsdom/lib/jsdom/living/generated/EventListenerOptions.js
generated
vendored
@@ -3,28 +3,26 @@
|
||||
const conversions = require("webidl-conversions");
|
||||
const utils = require("./utils.js");
|
||||
|
||||
module.exports = {
|
||||
convertInherit(obj, ret, { context = "The provided value" } = {}) {
|
||||
{
|
||||
const key = "capture";
|
||||
let value = obj === undefined || obj === null ? undefined : obj[key];
|
||||
if (value !== undefined) {
|
||||
value = conversions["boolean"](value, { context: context + " has member capture that" });
|
||||
exports._convertInherit = (obj, ret, { context = "The provided value" } = {}) => {
|
||||
{
|
||||
const key = "capture";
|
||||
let value = obj === undefined || obj === null ? undefined : obj[key];
|
||||
if (value !== undefined) {
|
||||
value = conversions["boolean"](value, { context: context + " has member 'capture' that" });
|
||||
|
||||
ret[key] = value;
|
||||
} else {
|
||||
ret[key] = false;
|
||||
}
|
||||
ret[key] = value;
|
||||
} else {
|
||||
ret[key] = false;
|
||||
}
|
||||
},
|
||||
|
||||
convert(obj, { context = "The provided value" } = {}) {
|
||||
if (obj !== undefined && typeof obj !== "object" && typeof obj !== "function") {
|
||||
throw new TypeError(`${context} is not an object.`);
|
||||
}
|
||||
|
||||
const ret = Object.create(null);
|
||||
module.exports.convertInherit(obj, ret, { context });
|
||||
return ret;
|
||||
}
|
||||
};
|
||||
|
||||
exports.convert = function convert(obj, { context = "The provided value" } = {}) {
|
||||
if (obj !== undefined && typeof obj !== "object" && typeof obj !== "function") {
|
||||
throw new TypeError(`${context} is not an object.`);
|
||||
}
|
||||
|
||||
const ret = Object.create(null);
|
||||
exports._convertInherit(obj, ret, { context });
|
||||
return ret;
|
||||
};
|
||||
|
||||
276
node_modules/jsdom/lib/jsdom/living/generated/EventModifierInit.js
generated
vendored
276
node_modules/jsdom/lib/jsdom/living/generated/EventModifierInit.js
generated
vendored
@@ -5,186 +5,184 @@ const utils = require("./utils.js");
|
||||
|
||||
const UIEventInit = require("./UIEventInit.js");
|
||||
|
||||
module.exports = {
|
||||
convertInherit(obj, ret, { context = "The provided value" } = {}) {
|
||||
UIEventInit.convertInherit(obj, ret, { context });
|
||||
exports._convertInherit = (obj, ret, { context = "The provided value" } = {}) => {
|
||||
UIEventInit._convertInherit(obj, ret, { context });
|
||||
|
||||
{
|
||||
const key = "altKey";
|
||||
let value = obj === undefined || obj === null ? undefined : obj[key];
|
||||
if (value !== undefined) {
|
||||
value = conversions["boolean"](value, { context: context + " has member altKey that" });
|
||||
{
|
||||
const key = "altKey";
|
||||
let value = obj === undefined || obj === null ? undefined : obj[key];
|
||||
if (value !== undefined) {
|
||||
value = conversions["boolean"](value, { context: context + " has member 'altKey' that" });
|
||||
|
||||
ret[key] = value;
|
||||
} else {
|
||||
ret[key] = false;
|
||||
}
|
||||
ret[key] = value;
|
||||
} else {
|
||||
ret[key] = false;
|
||||
}
|
||||
}
|
||||
|
||||
{
|
||||
const key = "ctrlKey";
|
||||
let value = obj === undefined || obj === null ? undefined : obj[key];
|
||||
if (value !== undefined) {
|
||||
value = conversions["boolean"](value, { context: context + " has member ctrlKey that" });
|
||||
{
|
||||
const key = "ctrlKey";
|
||||
let value = obj === undefined || obj === null ? undefined : obj[key];
|
||||
if (value !== undefined) {
|
||||
value = conversions["boolean"](value, { context: context + " has member 'ctrlKey' that" });
|
||||
|
||||
ret[key] = value;
|
||||
} else {
|
||||
ret[key] = false;
|
||||
}
|
||||
ret[key] = value;
|
||||
} else {
|
||||
ret[key] = false;
|
||||
}
|
||||
}
|
||||
|
||||
{
|
||||
const key = "metaKey";
|
||||
let value = obj === undefined || obj === null ? undefined : obj[key];
|
||||
if (value !== undefined) {
|
||||
value = conversions["boolean"](value, { context: context + " has member metaKey that" });
|
||||
{
|
||||
const key = "metaKey";
|
||||
let value = obj === undefined || obj === null ? undefined : obj[key];
|
||||
if (value !== undefined) {
|
||||
value = conversions["boolean"](value, { context: context + " has member 'metaKey' that" });
|
||||
|
||||
ret[key] = value;
|
||||
} else {
|
||||
ret[key] = false;
|
||||
}
|
||||
ret[key] = value;
|
||||
} else {
|
||||
ret[key] = false;
|
||||
}
|
||||
}
|
||||
|
||||
{
|
||||
const key = "modifierAltGraph";
|
||||
let value = obj === undefined || obj === null ? undefined : obj[key];
|
||||
if (value !== undefined) {
|
||||
value = conversions["boolean"](value, { context: context + " has member modifierAltGraph that" });
|
||||
{
|
||||
const key = "modifierAltGraph";
|
||||
let value = obj === undefined || obj === null ? undefined : obj[key];
|
||||
if (value !== undefined) {
|
||||
value = conversions["boolean"](value, { context: context + " has member 'modifierAltGraph' that" });
|
||||
|
||||
ret[key] = value;
|
||||
} else {
|
||||
ret[key] = false;
|
||||
}
|
||||
ret[key] = value;
|
||||
} else {
|
||||
ret[key] = false;
|
||||
}
|
||||
}
|
||||
|
||||
{
|
||||
const key = "modifierCapsLock";
|
||||
let value = obj === undefined || obj === null ? undefined : obj[key];
|
||||
if (value !== undefined) {
|
||||
value = conversions["boolean"](value, { context: context + " has member modifierCapsLock that" });
|
||||
{
|
||||
const key = "modifierCapsLock";
|
||||
let value = obj === undefined || obj === null ? undefined : obj[key];
|
||||
if (value !== undefined) {
|
||||
value = conversions["boolean"](value, { context: context + " has member 'modifierCapsLock' that" });
|
||||
|
||||
ret[key] = value;
|
||||
} else {
|
||||
ret[key] = false;
|
||||
}
|
||||
ret[key] = value;
|
||||
} else {
|
||||
ret[key] = false;
|
||||
}
|
||||
}
|
||||
|
||||
{
|
||||
const key = "modifierFn";
|
||||
let value = obj === undefined || obj === null ? undefined : obj[key];
|
||||
if (value !== undefined) {
|
||||
value = conversions["boolean"](value, { context: context + " has member modifierFn that" });
|
||||
{
|
||||
const key = "modifierFn";
|
||||
let value = obj === undefined || obj === null ? undefined : obj[key];
|
||||
if (value !== undefined) {
|
||||
value = conversions["boolean"](value, { context: context + " has member 'modifierFn' that" });
|
||||
|
||||
ret[key] = value;
|
||||
} else {
|
||||
ret[key] = false;
|
||||
}
|
||||
ret[key] = value;
|
||||
} else {
|
||||
ret[key] = false;
|
||||
}
|
||||
}
|
||||
|
||||
{
|
||||
const key = "modifierFnLock";
|
||||
let value = obj === undefined || obj === null ? undefined : obj[key];
|
||||
if (value !== undefined) {
|
||||
value = conversions["boolean"](value, { context: context + " has member modifierFnLock that" });
|
||||
{
|
||||
const key = "modifierFnLock";
|
||||
let value = obj === undefined || obj === null ? undefined : obj[key];
|
||||
if (value !== undefined) {
|
||||
value = conversions["boolean"](value, { context: context + " has member 'modifierFnLock' that" });
|
||||
|
||||
ret[key] = value;
|
||||
} else {
|
||||
ret[key] = false;
|
||||
}
|
||||
ret[key] = value;
|
||||
} else {
|
||||
ret[key] = false;
|
||||
}
|
||||
}
|
||||
|
||||
{
|
||||
const key = "modifierHyper";
|
||||
let value = obj === undefined || obj === null ? undefined : obj[key];
|
||||
if (value !== undefined) {
|
||||
value = conversions["boolean"](value, { context: context + " has member modifierHyper that" });
|
||||
{
|
||||
const key = "modifierHyper";
|
||||
let value = obj === undefined || obj === null ? undefined : obj[key];
|
||||
if (value !== undefined) {
|
||||
value = conversions["boolean"](value, { context: context + " has member 'modifierHyper' that" });
|
||||
|
||||
ret[key] = value;
|
||||
} else {
|
||||
ret[key] = false;
|
||||
}
|
||||
ret[key] = value;
|
||||
} else {
|
||||
ret[key] = false;
|
||||
}
|
||||
}
|
||||
|
||||
{
|
||||
const key = "modifierNumLock";
|
||||
let value = obj === undefined || obj === null ? undefined : obj[key];
|
||||
if (value !== undefined) {
|
||||
value = conversions["boolean"](value, { context: context + " has member modifierNumLock that" });
|
||||
{
|
||||
const key = "modifierNumLock";
|
||||
let value = obj === undefined || obj === null ? undefined : obj[key];
|
||||
if (value !== undefined) {
|
||||
value = conversions["boolean"](value, { context: context + " has member 'modifierNumLock' that" });
|
||||
|
||||
ret[key] = value;
|
||||
} else {
|
||||
ret[key] = false;
|
||||
}
|
||||
ret[key] = value;
|
||||
} else {
|
||||
ret[key] = false;
|
||||
}
|
||||
}
|
||||
|
||||
{
|
||||
const key = "modifierScrollLock";
|
||||
let value = obj === undefined || obj === null ? undefined : obj[key];
|
||||
if (value !== undefined) {
|
||||
value = conversions["boolean"](value, { context: context + " has member modifierScrollLock that" });
|
||||
{
|
||||
const key = "modifierScrollLock";
|
||||
let value = obj === undefined || obj === null ? undefined : obj[key];
|
||||
if (value !== undefined) {
|
||||
value = conversions["boolean"](value, { context: context + " has member 'modifierScrollLock' that" });
|
||||
|
||||
ret[key] = value;
|
||||
} else {
|
||||
ret[key] = false;
|
||||
}
|
||||
ret[key] = value;
|
||||
} else {
|
||||
ret[key] = false;
|
||||
}
|
||||
}
|
||||
|
||||
{
|
||||
const key = "modifierSuper";
|
||||
let value = obj === undefined || obj === null ? undefined : obj[key];
|
||||
if (value !== undefined) {
|
||||
value = conversions["boolean"](value, { context: context + " has member modifierSuper that" });
|
||||
{
|
||||
const key = "modifierSuper";
|
||||
let value = obj === undefined || obj === null ? undefined : obj[key];
|
||||
if (value !== undefined) {
|
||||
value = conversions["boolean"](value, { context: context + " has member 'modifierSuper' that" });
|
||||
|
||||
ret[key] = value;
|
||||
} else {
|
||||
ret[key] = false;
|
||||
}
|
||||
ret[key] = value;
|
||||
} else {
|
||||
ret[key] = false;
|
||||
}
|
||||
}
|
||||
|
||||
{
|
||||
const key = "modifierSymbol";
|
||||
let value = obj === undefined || obj === null ? undefined : obj[key];
|
||||
if (value !== undefined) {
|
||||
value = conversions["boolean"](value, { context: context + " has member modifierSymbol that" });
|
||||
{
|
||||
const key = "modifierSymbol";
|
||||
let value = obj === undefined || obj === null ? undefined : obj[key];
|
||||
if (value !== undefined) {
|
||||
value = conversions["boolean"](value, { context: context + " has member 'modifierSymbol' that" });
|
||||
|
||||
ret[key] = value;
|
||||
} else {
|
||||
ret[key] = false;
|
||||
}
|
||||
ret[key] = value;
|
||||
} else {
|
||||
ret[key] = false;
|
||||
}
|
||||
}
|
||||
|
||||
{
|
||||
const key = "modifierSymbolLock";
|
||||
let value = obj === undefined || obj === null ? undefined : obj[key];
|
||||
if (value !== undefined) {
|
||||
value = conversions["boolean"](value, { context: context + " has member modifierSymbolLock that" });
|
||||
{
|
||||
const key = "modifierSymbolLock";
|
||||
let value = obj === undefined || obj === null ? undefined : obj[key];
|
||||
if (value !== undefined) {
|
||||
value = conversions["boolean"](value, { context: context + " has member 'modifierSymbolLock' that" });
|
||||
|
||||
ret[key] = value;
|
||||
} else {
|
||||
ret[key] = false;
|
||||
}
|
||||
ret[key] = value;
|
||||
} else {
|
||||
ret[key] = false;
|
||||
}
|
||||
}
|
||||
|
||||
{
|
||||
const key = "shiftKey";
|
||||
let value = obj === undefined || obj === null ? undefined : obj[key];
|
||||
if (value !== undefined) {
|
||||
value = conversions["boolean"](value, { context: context + " has member shiftKey that" });
|
||||
{
|
||||
const key = "shiftKey";
|
||||
let value = obj === undefined || obj === null ? undefined : obj[key];
|
||||
if (value !== undefined) {
|
||||
value = conversions["boolean"](value, { context: context + " has member 'shiftKey' that" });
|
||||
|
||||
ret[key] = value;
|
||||
} else {
|
||||
ret[key] = false;
|
||||
}
|
||||
ret[key] = value;
|
||||
} else {
|
||||
ret[key] = false;
|
||||
}
|
||||
},
|
||||
|
||||
convert(obj, { context = "The provided value" } = {}) {
|
||||
if (obj !== undefined && typeof obj !== "object" && typeof obj !== "function") {
|
||||
throw new TypeError(`${context} is not an object.`);
|
||||
}
|
||||
|
||||
const ret = Object.create(null);
|
||||
module.exports.convertInherit(obj, ret, { context });
|
||||
return ret;
|
||||
}
|
||||
};
|
||||
|
||||
exports.convert = function convert(obj, { context = "The provided value" } = {}) {
|
||||
if (obj !== undefined && typeof obj !== "object" && typeof obj !== "function") {
|
||||
throw new TypeError(`${context} is not an object.`);
|
||||
}
|
||||
|
||||
const ret = Object.create(null);
|
||||
exports._convertInherit(obj, ret, { context });
|
||||
return ret;
|
||||
};
|
||||
|
||||
434
node_modules/jsdom/lib/jsdom/living/generated/EventTarget.js
generated
vendored
434
node_modules/jsdom/lib/jsdom/living/generated/EventTarget.js
generated
vendored
@@ -3,244 +3,250 @@
|
||||
const conversions = require("webidl-conversions");
|
||||
const utils = require("./utils.js");
|
||||
|
||||
const convertAddEventListenerOptions = require("./AddEventListenerOptions.js").convert;
|
||||
const convertEventListenerOptions = require("./EventListenerOptions.js").convert;
|
||||
const convertEvent = require("./Event.js").convert;
|
||||
const impl = utils.implSymbol;
|
||||
const EventListener = require("./EventListener.js");
|
||||
const AddEventListenerOptions = require("./AddEventListenerOptions.js");
|
||||
const EventListenerOptions = require("./EventListenerOptions.js");
|
||||
const Event = require("./Event.js");
|
||||
const implSymbol = utils.implSymbol;
|
||||
const ctorRegistrySymbol = utils.ctorRegistrySymbol;
|
||||
|
||||
function EventTarget() {
|
||||
if (new.target === undefined) {
|
||||
throw new TypeError(
|
||||
"Failed to construct 'EventTarget'. Please use the 'new' operator; this constructor " +
|
||||
"cannot be called as a function."
|
||||
);
|
||||
const interfaceName = "EventTarget";
|
||||
|
||||
exports.is = value => {
|
||||
return utils.isObject(value) && utils.hasOwn(value, implSymbol) && value[implSymbol] instanceof Impl.implementation;
|
||||
};
|
||||
exports.isImpl = value => {
|
||||
return utils.isObject(value) && value instanceof Impl.implementation;
|
||||
};
|
||||
exports.convert = (value, { context = "The provided value" } = {}) => {
|
||||
if (exports.is(value)) {
|
||||
return utils.implForWrapper(value);
|
||||
}
|
||||
throw new TypeError(`${context} is not of type 'EventTarget'.`);
|
||||
};
|
||||
|
||||
function makeWrapper(globalObject) {
|
||||
if (globalObject[ctorRegistrySymbol] === undefined) {
|
||||
throw new Error("Internal error: invalid global object");
|
||||
}
|
||||
|
||||
iface.setup(this);
|
||||
const ctor = globalObject[ctorRegistrySymbol]["EventTarget"];
|
||||
if (ctor === undefined) {
|
||||
throw new Error("Internal error: constructor EventTarget is not installed on the passed global object");
|
||||
}
|
||||
|
||||
return Object.create(ctor.prototype);
|
||||
}
|
||||
|
||||
Object.defineProperty(EventTarget, "prototype", {
|
||||
value: EventTarget.prototype,
|
||||
writable: false,
|
||||
enumerable: false,
|
||||
configurable: false
|
||||
});
|
||||
|
||||
EventTarget.prototype.addEventListener = function addEventListener(type, callback) {
|
||||
if (!this || !module.exports.is(this)) {
|
||||
throw new TypeError("Illegal invocation");
|
||||
}
|
||||
|
||||
if (arguments.length < 2) {
|
||||
throw new TypeError(
|
||||
"Failed to execute 'addEventListener' on 'EventTarget': 2 arguments required, but only " +
|
||||
arguments.length +
|
||||
" present."
|
||||
);
|
||||
}
|
||||
const args = [];
|
||||
{
|
||||
let curArg = arguments[0];
|
||||
curArg = conversions["DOMString"](curArg, {
|
||||
context: "Failed to execute 'addEventListener' on 'EventTarget': parameter 1"
|
||||
});
|
||||
args.push(curArg);
|
||||
}
|
||||
{
|
||||
let curArg = arguments[1];
|
||||
if (curArg === null || curArg === undefined) {
|
||||
curArg = null;
|
||||
} else {
|
||||
curArg = utils.tryImplForWrapper(curArg);
|
||||
}
|
||||
args.push(curArg);
|
||||
}
|
||||
{
|
||||
let curArg = arguments[2];
|
||||
if (curArg !== undefined) {
|
||||
if (curArg === null || curArg === undefined) {
|
||||
curArg = convertAddEventListenerOptions(curArg, {
|
||||
context: "Failed to execute 'addEventListener' on 'EventTarget': parameter 3"
|
||||
});
|
||||
} else if (utils.isObject(curArg)) {
|
||||
curArg = convertAddEventListenerOptions(curArg, {
|
||||
context: "Failed to execute 'addEventListener' on 'EventTarget': parameter 3" + " dictionary"
|
||||
});
|
||||
} else if (typeof curArg === "boolean") {
|
||||
curArg = conversions["boolean"](curArg, {
|
||||
context: "Failed to execute 'addEventListener' on 'EventTarget': parameter 3"
|
||||
});
|
||||
} else {
|
||||
curArg = conversions["boolean"](curArg, {
|
||||
context: "Failed to execute 'addEventListener' on 'EventTarget': parameter 3"
|
||||
});
|
||||
}
|
||||
}
|
||||
args.push(curArg);
|
||||
}
|
||||
return this[impl].addEventListener(...args);
|
||||
exports.create = (globalObject, constructorArgs, privateData) => {
|
||||
const wrapper = makeWrapper(globalObject);
|
||||
return exports.setup(wrapper, globalObject, constructorArgs, privateData);
|
||||
};
|
||||
|
||||
EventTarget.prototype.removeEventListener = function removeEventListener(type, callback) {
|
||||
if (!this || !module.exports.is(this)) {
|
||||
throw new TypeError("Illegal invocation");
|
||||
}
|
||||
|
||||
if (arguments.length < 2) {
|
||||
throw new TypeError(
|
||||
"Failed to execute 'removeEventListener' on 'EventTarget': 2 arguments required, but only " +
|
||||
arguments.length +
|
||||
" present."
|
||||
);
|
||||
}
|
||||
const args = [];
|
||||
{
|
||||
let curArg = arguments[0];
|
||||
curArg = conversions["DOMString"](curArg, {
|
||||
context: "Failed to execute 'removeEventListener' on 'EventTarget': parameter 1"
|
||||
});
|
||||
args.push(curArg);
|
||||
}
|
||||
{
|
||||
let curArg = arguments[1];
|
||||
if (curArg === null || curArg === undefined) {
|
||||
curArg = null;
|
||||
} else {
|
||||
curArg = utils.tryImplForWrapper(curArg);
|
||||
}
|
||||
args.push(curArg);
|
||||
}
|
||||
{
|
||||
let curArg = arguments[2];
|
||||
if (curArg !== undefined) {
|
||||
if (curArg === null || curArg === undefined) {
|
||||
curArg = convertEventListenerOptions(curArg, {
|
||||
context: "Failed to execute 'removeEventListener' on 'EventTarget': parameter 3"
|
||||
});
|
||||
} else if (utils.isObject(curArg)) {
|
||||
curArg = convertEventListenerOptions(curArg, {
|
||||
context: "Failed to execute 'removeEventListener' on 'EventTarget': parameter 3" + " dictionary"
|
||||
});
|
||||
} else if (typeof curArg === "boolean") {
|
||||
curArg = conversions["boolean"](curArg, {
|
||||
context: "Failed to execute 'removeEventListener' on 'EventTarget': parameter 3"
|
||||
});
|
||||
} else {
|
||||
curArg = conversions["boolean"](curArg, {
|
||||
context: "Failed to execute 'removeEventListener' on 'EventTarget': parameter 3"
|
||||
});
|
||||
}
|
||||
}
|
||||
args.push(curArg);
|
||||
}
|
||||
return this[impl].removeEventListener(...args);
|
||||
exports.createImpl = (globalObject, constructorArgs, privateData) => {
|
||||
const wrapper = exports.create(globalObject, constructorArgs, privateData);
|
||||
return utils.implForWrapper(wrapper);
|
||||
};
|
||||
|
||||
EventTarget.prototype.dispatchEvent = function dispatchEvent(event) {
|
||||
if (!this || !module.exports.is(this)) {
|
||||
throw new TypeError("Illegal invocation");
|
||||
}
|
||||
exports._internalSetup = (wrapper, globalObject) => {};
|
||||
|
||||
if (arguments.length < 1) {
|
||||
throw new TypeError(
|
||||
"Failed to execute 'dispatchEvent' on 'EventTarget': 1 argument required, but only " +
|
||||
arguments.length +
|
||||
" present."
|
||||
);
|
||||
exports.setup = (wrapper, globalObject, constructorArgs = [], privateData = {}) => {
|
||||
privateData.wrapper = wrapper;
|
||||
|
||||
exports._internalSetup(wrapper, globalObject);
|
||||
Object.defineProperty(wrapper, implSymbol, {
|
||||
value: new Impl.implementation(globalObject, constructorArgs, privateData),
|
||||
configurable: true
|
||||
});
|
||||
|
||||
wrapper[implSymbol][utils.wrapperSymbol] = wrapper;
|
||||
if (Impl.init) {
|
||||
Impl.init(wrapper[implSymbol]);
|
||||
}
|
||||
const args = [];
|
||||
{
|
||||
let curArg = arguments[0];
|
||||
curArg = convertEvent(curArg, { context: "Failed to execute 'dispatchEvent' on 'EventTarget': parameter 1" });
|
||||
args.push(curArg);
|
||||
}
|
||||
return this[impl].dispatchEvent(...args);
|
||||
return wrapper;
|
||||
};
|
||||
|
||||
Object.defineProperty(EventTarget.prototype, Symbol.toStringTag, {
|
||||
value: "EventTarget",
|
||||
writable: false,
|
||||
enumerable: false,
|
||||
configurable: true
|
||||
});
|
||||
exports.new = globalObject => {
|
||||
const wrapper = makeWrapper(globalObject);
|
||||
|
||||
const iface = {
|
||||
// When an interface-module that implements this interface as a mixin is loaded, it will append its own `.is()`
|
||||
// method into this array. It allows objects that directly implements *those* interfaces to be recognized as
|
||||
// implementing this mixin interface.
|
||||
_mixedIntoPredicates: [],
|
||||
is(obj) {
|
||||
if (obj) {
|
||||
if (utils.hasOwn(obj, impl) && obj[impl] instanceof Impl.implementation) {
|
||||
return true;
|
||||
exports._internalSetup(wrapper, globalObject);
|
||||
Object.defineProperty(wrapper, implSymbol, {
|
||||
value: Object.create(Impl.implementation.prototype),
|
||||
configurable: true
|
||||
});
|
||||
|
||||
wrapper[implSymbol][utils.wrapperSymbol] = wrapper;
|
||||
if (Impl.init) {
|
||||
Impl.init(wrapper[implSymbol]);
|
||||
}
|
||||
return wrapper[implSymbol];
|
||||
};
|
||||
|
||||
const exposed = new Set(["Window", "Worker", "AudioWorklet"]);
|
||||
|
||||
exports.install = (globalObject, globalNames) => {
|
||||
if (!globalNames.some(globalName => exposed.has(globalName))) {
|
||||
return;
|
||||
}
|
||||
class EventTarget {
|
||||
constructor() {
|
||||
return exports.setup(Object.create(new.target.prototype), globalObject, undefined);
|
||||
}
|
||||
|
||||
addEventListener(type, callback) {
|
||||
const esValue = this !== null && this !== undefined ? this : globalObject;
|
||||
if (!exports.is(esValue)) {
|
||||
throw new TypeError("Illegal invocation");
|
||||
}
|
||||
for (const isMixedInto of module.exports._mixedIntoPredicates) {
|
||||
if (isMixedInto(obj)) {
|
||||
return true;
|
||||
|
||||
if (arguments.length < 2) {
|
||||
throw new TypeError(
|
||||
"Failed to execute 'addEventListener' on 'EventTarget': 2 arguments required, but only " +
|
||||
arguments.length +
|
||||
" present."
|
||||
);
|
||||
}
|
||||
const args = [];
|
||||
{
|
||||
let curArg = arguments[0];
|
||||
curArg = conversions["DOMString"](curArg, {
|
||||
context: "Failed to execute 'addEventListener' on 'EventTarget': parameter 1"
|
||||
});
|
||||
args.push(curArg);
|
||||
}
|
||||
{
|
||||
let curArg = arguments[1];
|
||||
if (curArg === null || curArg === undefined) {
|
||||
curArg = null;
|
||||
} else {
|
||||
curArg = EventListener.convert(curArg, {
|
||||
context: "Failed to execute 'addEventListener' on 'EventTarget': parameter 2"
|
||||
});
|
||||
}
|
||||
args.push(curArg);
|
||||
}
|
||||
}
|
||||
return false;
|
||||
},
|
||||
isImpl(obj) {
|
||||
if (obj) {
|
||||
if (obj instanceof Impl.implementation) {
|
||||
return true;
|
||||
}
|
||||
|
||||
const wrapper = utils.wrapperForImpl(obj);
|
||||
for (const isMixedInto of module.exports._mixedIntoPredicates) {
|
||||
if (isMixedInto(wrapper)) {
|
||||
return true;
|
||||
{
|
||||
let curArg = arguments[2];
|
||||
if (curArg !== undefined) {
|
||||
if (curArg === null || curArg === undefined) {
|
||||
curArg = AddEventListenerOptions.convert(curArg, {
|
||||
context: "Failed to execute 'addEventListener' on 'EventTarget': parameter 3"
|
||||
});
|
||||
} else if (utils.isObject(curArg)) {
|
||||
curArg = AddEventListenerOptions.convert(curArg, {
|
||||
context: "Failed to execute 'addEventListener' on 'EventTarget': parameter 3" + " dictionary"
|
||||
});
|
||||
} else if (typeof curArg === "boolean") {
|
||||
curArg = conversions["boolean"](curArg, {
|
||||
context: "Failed to execute 'addEventListener' on 'EventTarget': parameter 3"
|
||||
});
|
||||
} else {
|
||||
curArg = conversions["boolean"](curArg, {
|
||||
context: "Failed to execute 'addEventListener' on 'EventTarget': parameter 3"
|
||||
});
|
||||
}
|
||||
}
|
||||
args.push(curArg);
|
||||
}
|
||||
return esValue[implSymbol].addEventListener(...args);
|
||||
}
|
||||
return false;
|
||||
},
|
||||
convert(obj, { context = "The provided value" } = {}) {
|
||||
if (module.exports.is(obj)) {
|
||||
return utils.implForWrapper(obj);
|
||||
|
||||
removeEventListener(type, callback) {
|
||||
const esValue = this !== null && this !== undefined ? this : globalObject;
|
||||
if (!exports.is(esValue)) {
|
||||
throw new TypeError("Illegal invocation");
|
||||
}
|
||||
|
||||
if (arguments.length < 2) {
|
||||
throw new TypeError(
|
||||
"Failed to execute 'removeEventListener' on 'EventTarget': 2 arguments required, but only " +
|
||||
arguments.length +
|
||||
" present."
|
||||
);
|
||||
}
|
||||
const args = [];
|
||||
{
|
||||
let curArg = arguments[0];
|
||||
curArg = conversions["DOMString"](curArg, {
|
||||
context: "Failed to execute 'removeEventListener' on 'EventTarget': parameter 1"
|
||||
});
|
||||
args.push(curArg);
|
||||
}
|
||||
{
|
||||
let curArg = arguments[1];
|
||||
if (curArg === null || curArg === undefined) {
|
||||
curArg = null;
|
||||
} else {
|
||||
curArg = EventListener.convert(curArg, {
|
||||
context: "Failed to execute 'removeEventListener' on 'EventTarget': parameter 2"
|
||||
});
|
||||
}
|
||||
args.push(curArg);
|
||||
}
|
||||
{
|
||||
let curArg = arguments[2];
|
||||
if (curArg !== undefined) {
|
||||
if (curArg === null || curArg === undefined) {
|
||||
curArg = EventListenerOptions.convert(curArg, {
|
||||
context: "Failed to execute 'removeEventListener' on 'EventTarget': parameter 3"
|
||||
});
|
||||
} else if (utils.isObject(curArg)) {
|
||||
curArg = EventListenerOptions.convert(curArg, {
|
||||
context: "Failed to execute 'removeEventListener' on 'EventTarget': parameter 3" + " dictionary"
|
||||
});
|
||||
} else if (typeof curArg === "boolean") {
|
||||
curArg = conversions["boolean"](curArg, {
|
||||
context: "Failed to execute 'removeEventListener' on 'EventTarget': parameter 3"
|
||||
});
|
||||
} else {
|
||||
curArg = conversions["boolean"](curArg, {
|
||||
context: "Failed to execute 'removeEventListener' on 'EventTarget': parameter 3"
|
||||
});
|
||||
}
|
||||
}
|
||||
args.push(curArg);
|
||||
}
|
||||
return esValue[implSymbol].removeEventListener(...args);
|
||||
}
|
||||
throw new TypeError(`${context} is not of type 'EventTarget'.`);
|
||||
},
|
||||
|
||||
create(constructorArgs, privateData) {
|
||||
let obj = Object.create(EventTarget.prototype);
|
||||
obj = this.setup(obj, constructorArgs, privateData);
|
||||
return obj;
|
||||
},
|
||||
createImpl(constructorArgs, privateData) {
|
||||
let obj = Object.create(EventTarget.prototype);
|
||||
obj = this.setup(obj, constructorArgs, privateData);
|
||||
return utils.implForWrapper(obj);
|
||||
},
|
||||
_internalSetup(obj) {},
|
||||
setup(obj, constructorArgs, privateData) {
|
||||
if (!privateData) privateData = {};
|
||||
dispatchEvent(event) {
|
||||
const esValue = this !== null && this !== undefined ? this : globalObject;
|
||||
if (!exports.is(esValue)) {
|
||||
throw new TypeError("Illegal invocation");
|
||||
}
|
||||
|
||||
privateData.wrapper = obj;
|
||||
|
||||
this._internalSetup(obj);
|
||||
Object.defineProperty(obj, impl, {
|
||||
value: new Impl.implementation(constructorArgs, privateData),
|
||||
writable: false,
|
||||
enumerable: false,
|
||||
configurable: true
|
||||
});
|
||||
|
||||
obj[impl][utils.wrapperSymbol] = obj;
|
||||
if (Impl.init) {
|
||||
Impl.init(obj[impl], privateData);
|
||||
if (arguments.length < 1) {
|
||||
throw new TypeError(
|
||||
"Failed to execute 'dispatchEvent' on 'EventTarget': 1 argument required, but only " +
|
||||
arguments.length +
|
||||
" present."
|
||||
);
|
||||
}
|
||||
const args = [];
|
||||
{
|
||||
let curArg = arguments[0];
|
||||
curArg = Event.convert(curArg, { context: "Failed to execute 'dispatchEvent' on 'EventTarget': parameter 1" });
|
||||
args.push(curArg);
|
||||
}
|
||||
return esValue[implSymbol].dispatchEvent(...args);
|
||||
}
|
||||
return obj;
|
||||
},
|
||||
interface: EventTarget,
|
||||
expose: {
|
||||
Window: { EventTarget },
|
||||
Worker: { EventTarget },
|
||||
AudioWorklet: { EventTarget }
|
||||
}
|
||||
}; // iface
|
||||
module.exports = iface;
|
||||
Object.defineProperties(EventTarget.prototype, {
|
||||
addEventListener: { enumerable: true },
|
||||
removeEventListener: { enumerable: true },
|
||||
dispatchEvent: { enumerable: true },
|
||||
[Symbol.toStringTag]: { value: "EventTarget", configurable: true }
|
||||
});
|
||||
if (globalObject[ctorRegistrySymbol] === undefined) {
|
||||
globalObject[ctorRegistrySymbol] = Object.create(null);
|
||||
}
|
||||
globalObject[ctorRegistrySymbol][interfaceName] = EventTarget;
|
||||
|
||||
Object.defineProperty(globalObject, interfaceName, {
|
||||
configurable: true,
|
||||
writable: true,
|
||||
value: EventTarget
|
||||
});
|
||||
};
|
||||
|
||||
const Impl = require("../events/EventTarget-impl.js");
|
||||
|
||||
202
node_modules/jsdom/lib/jsdom/living/generated/External.js
generated
vendored
202
node_modules/jsdom/lib/jsdom/living/generated/External.js
generated
vendored
@@ -3,115 +3,125 @@
|
||||
const conversions = require("webidl-conversions");
|
||||
const utils = require("./utils.js");
|
||||
|
||||
const impl = utils.implSymbol;
|
||||
const implSymbol = utils.implSymbol;
|
||||
const ctorRegistrySymbol = utils.ctorRegistrySymbol;
|
||||
|
||||
function External() {
|
||||
throw new TypeError("Illegal constructor");
|
||||
const interfaceName = "External";
|
||||
|
||||
exports.is = value => {
|
||||
return utils.isObject(value) && utils.hasOwn(value, implSymbol) && value[implSymbol] instanceof Impl.implementation;
|
||||
};
|
||||
exports.isImpl = value => {
|
||||
return utils.isObject(value) && value instanceof Impl.implementation;
|
||||
};
|
||||
exports.convert = (value, { context = "The provided value" } = {}) => {
|
||||
if (exports.is(value)) {
|
||||
return utils.implForWrapper(value);
|
||||
}
|
||||
throw new TypeError(`${context} is not of type 'External'.`);
|
||||
};
|
||||
|
||||
function makeWrapper(globalObject) {
|
||||
if (globalObject[ctorRegistrySymbol] === undefined) {
|
||||
throw new Error("Internal error: invalid global object");
|
||||
}
|
||||
|
||||
const ctor = globalObject[ctorRegistrySymbol]["External"];
|
||||
if (ctor === undefined) {
|
||||
throw new Error("Internal error: constructor External is not installed on the passed global object");
|
||||
}
|
||||
|
||||
return Object.create(ctor.prototype);
|
||||
}
|
||||
|
||||
Object.defineProperty(External, "prototype", {
|
||||
value: External.prototype,
|
||||
writable: false,
|
||||
enumerable: false,
|
||||
configurable: false
|
||||
});
|
||||
|
||||
External.prototype.AddSearchProvider = function AddSearchProvider() {
|
||||
if (!this || !module.exports.is(this)) {
|
||||
throw new TypeError("Illegal invocation");
|
||||
}
|
||||
|
||||
return this[impl].AddSearchProvider();
|
||||
exports.create = (globalObject, constructorArgs, privateData) => {
|
||||
const wrapper = makeWrapper(globalObject);
|
||||
return exports.setup(wrapper, globalObject, constructorArgs, privateData);
|
||||
};
|
||||
|
||||
External.prototype.IsSearchProviderInstalled = function IsSearchProviderInstalled() {
|
||||
if (!this || !module.exports.is(this)) {
|
||||
throw new TypeError("Illegal invocation");
|
||||
}
|
||||
|
||||
return this[impl].IsSearchProviderInstalled();
|
||||
exports.createImpl = (globalObject, constructorArgs, privateData) => {
|
||||
const wrapper = exports.create(globalObject, constructorArgs, privateData);
|
||||
return utils.implForWrapper(wrapper);
|
||||
};
|
||||
|
||||
Object.defineProperty(External.prototype, Symbol.toStringTag, {
|
||||
value: "External",
|
||||
writable: false,
|
||||
enumerable: false,
|
||||
configurable: true
|
||||
});
|
||||
exports._internalSetup = (wrapper, globalObject) => {};
|
||||
|
||||
const iface = {
|
||||
// When an interface-module that implements this interface as a mixin is loaded, it will append its own `.is()`
|
||||
// method into this array. It allows objects that directly implements *those* interfaces to be recognized as
|
||||
// implementing this mixin interface.
|
||||
_mixedIntoPredicates: [],
|
||||
is(obj) {
|
||||
if (obj) {
|
||||
if (utils.hasOwn(obj, impl) && obj[impl] instanceof Impl.implementation) {
|
||||
return true;
|
||||
}
|
||||
for (const isMixedInto of module.exports._mixedIntoPredicates) {
|
||||
if (isMixedInto(obj)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
exports.setup = (wrapper, globalObject, constructorArgs = [], privateData = {}) => {
|
||||
privateData.wrapper = wrapper;
|
||||
|
||||
exports._internalSetup(wrapper, globalObject);
|
||||
Object.defineProperty(wrapper, implSymbol, {
|
||||
value: new Impl.implementation(globalObject, constructorArgs, privateData),
|
||||
configurable: true
|
||||
});
|
||||
|
||||
wrapper[implSymbol][utils.wrapperSymbol] = wrapper;
|
||||
if (Impl.init) {
|
||||
Impl.init(wrapper[implSymbol]);
|
||||
}
|
||||
return wrapper;
|
||||
};
|
||||
|
||||
exports.new = globalObject => {
|
||||
const wrapper = makeWrapper(globalObject);
|
||||
|
||||
exports._internalSetup(wrapper, globalObject);
|
||||
Object.defineProperty(wrapper, implSymbol, {
|
||||
value: Object.create(Impl.implementation.prototype),
|
||||
configurable: true
|
||||
});
|
||||
|
||||
wrapper[implSymbol][utils.wrapperSymbol] = wrapper;
|
||||
if (Impl.init) {
|
||||
Impl.init(wrapper[implSymbol]);
|
||||
}
|
||||
return wrapper[implSymbol];
|
||||
};
|
||||
|
||||
const exposed = new Set(["Window"]);
|
||||
|
||||
exports.install = (globalObject, globalNames) => {
|
||||
if (!globalNames.some(globalName => exposed.has(globalName))) {
|
||||
return;
|
||||
}
|
||||
class External {
|
||||
constructor() {
|
||||
throw new TypeError("Illegal constructor");
|
||||
}
|
||||
return false;
|
||||
},
|
||||
isImpl(obj) {
|
||||
if (obj) {
|
||||
if (obj instanceof Impl.implementation) {
|
||||
return true;
|
||||
|
||||
AddSearchProvider() {
|
||||
const esValue = this !== null && this !== undefined ? this : globalObject;
|
||||
if (!exports.is(esValue)) {
|
||||
throw new TypeError("Illegal invocation");
|
||||
}
|
||||
|
||||
const wrapper = utils.wrapperForImpl(obj);
|
||||
for (const isMixedInto of module.exports._mixedIntoPredicates) {
|
||||
if (isMixedInto(wrapper)) {
|
||||
return true;
|
||||
}
|
||||
return esValue[implSymbol].AddSearchProvider();
|
||||
}
|
||||
|
||||
IsSearchProviderInstalled() {
|
||||
const esValue = this !== null && this !== undefined ? this : globalObject;
|
||||
if (!exports.is(esValue)) {
|
||||
throw new TypeError("Illegal invocation");
|
||||
}
|
||||
|
||||
return esValue[implSymbol].IsSearchProviderInstalled();
|
||||
}
|
||||
return false;
|
||||
},
|
||||
convert(obj, { context = "The provided value" } = {}) {
|
||||
if (module.exports.is(obj)) {
|
||||
return utils.implForWrapper(obj);
|
||||
}
|
||||
throw new TypeError(`${context} is not of type 'External'.`);
|
||||
},
|
||||
}
|
||||
Object.defineProperties(External.prototype, {
|
||||
AddSearchProvider: { enumerable: true },
|
||||
IsSearchProviderInstalled: { enumerable: true },
|
||||
[Symbol.toStringTag]: { value: "External", configurable: true }
|
||||
});
|
||||
if (globalObject[ctorRegistrySymbol] === undefined) {
|
||||
globalObject[ctorRegistrySymbol] = Object.create(null);
|
||||
}
|
||||
globalObject[ctorRegistrySymbol][interfaceName] = External;
|
||||
|
||||
create(constructorArgs, privateData) {
|
||||
let obj = Object.create(External.prototype);
|
||||
obj = this.setup(obj, constructorArgs, privateData);
|
||||
return obj;
|
||||
},
|
||||
createImpl(constructorArgs, privateData) {
|
||||
let obj = Object.create(External.prototype);
|
||||
obj = this.setup(obj, constructorArgs, privateData);
|
||||
return utils.implForWrapper(obj);
|
||||
},
|
||||
_internalSetup(obj) {},
|
||||
setup(obj, constructorArgs, privateData) {
|
||||
if (!privateData) privateData = {};
|
||||
|
||||
privateData.wrapper = obj;
|
||||
|
||||
this._internalSetup(obj);
|
||||
Object.defineProperty(obj, impl, {
|
||||
value: new Impl.implementation(constructorArgs, privateData),
|
||||
writable: false,
|
||||
enumerable: false,
|
||||
configurable: true
|
||||
});
|
||||
|
||||
obj[impl][utils.wrapperSymbol] = obj;
|
||||
if (Impl.init) {
|
||||
Impl.init(obj[impl], privateData);
|
||||
}
|
||||
return obj;
|
||||
},
|
||||
interface: External,
|
||||
expose: {}
|
||||
}; // iface
|
||||
module.exports = iface;
|
||||
Object.defineProperty(globalObject, interfaceName, {
|
||||
configurable: true,
|
||||
writable: true,
|
||||
value: External
|
||||
});
|
||||
};
|
||||
|
||||
const Impl = require("../window/External-impl.js");
|
||||
|
||||
316
node_modules/jsdom/lib/jsdom/living/generated/File.js
generated
vendored
316
node_modules/jsdom/lib/jsdom/living/generated/File.js
generated
vendored
@@ -3,180 +3,174 @@
|
||||
const conversions = require("webidl-conversions");
|
||||
const utils = require("./utils.js");
|
||||
|
||||
const isBlob = require("./Blob.js").is;
|
||||
const convertFilePropertyBag = require("./FilePropertyBag.js").convert;
|
||||
const impl = utils.implSymbol;
|
||||
const Blob = require("./Blob.js");
|
||||
const FilePropertyBag = require("./FilePropertyBag.js");
|
||||
const implSymbol = utils.implSymbol;
|
||||
const ctorRegistrySymbol = utils.ctorRegistrySymbol;
|
||||
|
||||
function File(fileBits, fileName) {
|
||||
if (new.target === undefined) {
|
||||
throw new TypeError(
|
||||
"Failed to construct 'File'. Please use the 'new' operator; this constructor " + "cannot be called as a function."
|
||||
);
|
||||
const interfaceName = "File";
|
||||
|
||||
exports.is = value => {
|
||||
return utils.isObject(value) && utils.hasOwn(value, implSymbol) && value[implSymbol] instanceof Impl.implementation;
|
||||
};
|
||||
exports.isImpl = value => {
|
||||
return utils.isObject(value) && value instanceof Impl.implementation;
|
||||
};
|
||||
exports.convert = (value, { context = "The provided value" } = {}) => {
|
||||
if (exports.is(value)) {
|
||||
return utils.implForWrapper(value);
|
||||
}
|
||||
throw new TypeError(`${context} is not of type 'File'.`);
|
||||
};
|
||||
|
||||
function makeWrapper(globalObject) {
|
||||
if (globalObject[ctorRegistrySymbol] === undefined) {
|
||||
throw new Error("Internal error: invalid global object");
|
||||
}
|
||||
|
||||
if (arguments.length < 2) {
|
||||
throw new TypeError("Failed to construct 'File': 2 arguments required, but only " + arguments.length + " present.");
|
||||
}
|
||||
const args = [];
|
||||
{
|
||||
let curArg = arguments[0];
|
||||
if (!utils.isObject(curArg)) {
|
||||
throw new TypeError("Failed to construct 'File': parameter 1" + " is not an iterable object.");
|
||||
} else {
|
||||
const V = [];
|
||||
const tmp = curArg;
|
||||
for (let nextItem of tmp) {
|
||||
if (isBlob(nextItem)) {
|
||||
nextItem = utils.implForWrapper(nextItem);
|
||||
} else if (nextItem instanceof ArrayBuffer) {
|
||||
} else if (ArrayBuffer.isView(nextItem)) {
|
||||
} else {
|
||||
nextItem = conversions["USVString"](nextItem, {
|
||||
context: "Failed to construct 'File': parameter 1" + "'s element"
|
||||
});
|
||||
}
|
||||
V.push(nextItem);
|
||||
}
|
||||
curArg = V;
|
||||
}
|
||||
args.push(curArg);
|
||||
}
|
||||
{
|
||||
let curArg = arguments[1];
|
||||
curArg = conversions["USVString"](curArg, { context: "Failed to construct 'File': parameter 2" });
|
||||
args.push(curArg);
|
||||
}
|
||||
{
|
||||
let curArg = arguments[2];
|
||||
curArg = convertFilePropertyBag(curArg, { context: "Failed to construct 'File': parameter 3" });
|
||||
args.push(curArg);
|
||||
const ctor = globalObject[ctorRegistrySymbol]["File"];
|
||||
if (ctor === undefined) {
|
||||
throw new Error("Internal error: constructor File is not installed on the passed global object");
|
||||
}
|
||||
|
||||
iface.setup(this, args);
|
||||
return Object.create(ctor.prototype);
|
||||
}
|
||||
|
||||
Object.setPrototypeOf(File.prototype, Blob.interface.prototype);
|
||||
Object.setPrototypeOf(File, Blob.interface);
|
||||
exports.create = (globalObject, constructorArgs, privateData) => {
|
||||
const wrapper = makeWrapper(globalObject);
|
||||
return exports.setup(wrapper, globalObject, constructorArgs, privateData);
|
||||
};
|
||||
|
||||
Object.defineProperty(File, "prototype", {
|
||||
value: File.prototype,
|
||||
writable: false,
|
||||
enumerable: false,
|
||||
configurable: false
|
||||
});
|
||||
exports.createImpl = (globalObject, constructorArgs, privateData) => {
|
||||
const wrapper = exports.create(globalObject, constructorArgs, privateData);
|
||||
return utils.implForWrapper(wrapper);
|
||||
};
|
||||
|
||||
Object.defineProperty(File.prototype, "name", {
|
||||
get() {
|
||||
if (!this || !module.exports.is(this)) {
|
||||
throw new TypeError("Illegal invocation");
|
||||
}
|
||||
exports._internalSetup = (wrapper, globalObject) => {
|
||||
Blob._internalSetup(wrapper, globalObject);
|
||||
};
|
||||
|
||||
return this[impl]["name"];
|
||||
},
|
||||
exports.setup = (wrapper, globalObject, constructorArgs = [], privateData = {}) => {
|
||||
privateData.wrapper = wrapper;
|
||||
|
||||
enumerable: true,
|
||||
configurable: true
|
||||
});
|
||||
exports._internalSetup(wrapper, globalObject);
|
||||
Object.defineProperty(wrapper, implSymbol, {
|
||||
value: new Impl.implementation(globalObject, constructorArgs, privateData),
|
||||
configurable: true
|
||||
});
|
||||
|
||||
Object.defineProperty(File.prototype, "lastModified", {
|
||||
get() {
|
||||
if (!this || !module.exports.is(this)) {
|
||||
throw new TypeError("Illegal invocation");
|
||||
}
|
||||
|
||||
return this[impl]["lastModified"];
|
||||
},
|
||||
|
||||
enumerable: true,
|
||||
configurable: true
|
||||
});
|
||||
|
||||
Object.defineProperty(File.prototype, Symbol.toStringTag, {
|
||||
value: "File",
|
||||
writable: false,
|
||||
enumerable: false,
|
||||
configurable: true
|
||||
});
|
||||
|
||||
const iface = {
|
||||
// When an interface-module that implements this interface as a mixin is loaded, it will append its own `.is()`
|
||||
// method into this array. It allows objects that directly implements *those* interfaces to be recognized as
|
||||
// implementing this mixin interface.
|
||||
_mixedIntoPredicates: [],
|
||||
is(obj) {
|
||||
if (obj) {
|
||||
if (utils.hasOwn(obj, impl) && obj[impl] instanceof Impl.implementation) {
|
||||
return true;
|
||||
}
|
||||
for (const isMixedInto of module.exports._mixedIntoPredicates) {
|
||||
if (isMixedInto(obj)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
},
|
||||
isImpl(obj) {
|
||||
if (obj) {
|
||||
if (obj instanceof Impl.implementation) {
|
||||
return true;
|
||||
}
|
||||
|
||||
const wrapper = utils.wrapperForImpl(obj);
|
||||
for (const isMixedInto of module.exports._mixedIntoPredicates) {
|
||||
if (isMixedInto(wrapper)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
},
|
||||
convert(obj, { context = "The provided value" } = {}) {
|
||||
if (module.exports.is(obj)) {
|
||||
return utils.implForWrapper(obj);
|
||||
}
|
||||
throw new TypeError(`${context} is not of type 'File'.`);
|
||||
},
|
||||
|
||||
create(constructorArgs, privateData) {
|
||||
let obj = Object.create(File.prototype);
|
||||
obj = this.setup(obj, constructorArgs, privateData);
|
||||
return obj;
|
||||
},
|
||||
createImpl(constructorArgs, privateData) {
|
||||
let obj = Object.create(File.prototype);
|
||||
obj = this.setup(obj, constructorArgs, privateData);
|
||||
return utils.implForWrapper(obj);
|
||||
},
|
||||
_internalSetup(obj) {
|
||||
Blob._internalSetup(obj);
|
||||
},
|
||||
setup(obj, constructorArgs, privateData) {
|
||||
if (!privateData) privateData = {};
|
||||
|
||||
privateData.wrapper = obj;
|
||||
|
||||
this._internalSetup(obj);
|
||||
Object.defineProperty(obj, impl, {
|
||||
value: new Impl.implementation(constructorArgs, privateData),
|
||||
writable: false,
|
||||
enumerable: false,
|
||||
configurable: true
|
||||
});
|
||||
|
||||
obj[impl][utils.wrapperSymbol] = obj;
|
||||
if (Impl.init) {
|
||||
Impl.init(obj[impl], privateData);
|
||||
}
|
||||
return obj;
|
||||
},
|
||||
interface: File,
|
||||
expose: {
|
||||
Window: { File },
|
||||
Worker: { File }
|
||||
wrapper[implSymbol][utils.wrapperSymbol] = wrapper;
|
||||
if (Impl.init) {
|
||||
Impl.init(wrapper[implSymbol]);
|
||||
}
|
||||
}; // iface
|
||||
module.exports = iface;
|
||||
return wrapper;
|
||||
};
|
||||
|
||||
exports.new = globalObject => {
|
||||
const wrapper = makeWrapper(globalObject);
|
||||
|
||||
exports._internalSetup(wrapper, globalObject);
|
||||
Object.defineProperty(wrapper, implSymbol, {
|
||||
value: Object.create(Impl.implementation.prototype),
|
||||
configurable: true
|
||||
});
|
||||
|
||||
wrapper[implSymbol][utils.wrapperSymbol] = wrapper;
|
||||
if (Impl.init) {
|
||||
Impl.init(wrapper[implSymbol]);
|
||||
}
|
||||
return wrapper[implSymbol];
|
||||
};
|
||||
|
||||
const exposed = new Set(["Window", "Worker"]);
|
||||
|
||||
exports.install = (globalObject, globalNames) => {
|
||||
if (!globalNames.some(globalName => exposed.has(globalName))) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (globalObject.Blob === undefined) {
|
||||
throw new Error("Internal error: attempting to evaluate File before Blob");
|
||||
}
|
||||
class File extends globalObject.Blob {
|
||||
constructor(fileBits, fileName) {
|
||||
if (arguments.length < 2) {
|
||||
throw new TypeError(
|
||||
"Failed to construct 'File': 2 arguments required, but only " + arguments.length + " present."
|
||||
);
|
||||
}
|
||||
const args = [];
|
||||
{
|
||||
let curArg = arguments[0];
|
||||
if (!utils.isObject(curArg)) {
|
||||
throw new TypeError("Failed to construct 'File': parameter 1" + " is not an iterable object.");
|
||||
} else {
|
||||
const V = [];
|
||||
const tmp = curArg;
|
||||
for (let nextItem of tmp) {
|
||||
if (Blob.is(nextItem)) {
|
||||
nextItem = utils.implForWrapper(nextItem);
|
||||
} else if (utils.isArrayBuffer(nextItem)) {
|
||||
} else if (ArrayBuffer.isView(nextItem)) {
|
||||
} else {
|
||||
nextItem = conversions["USVString"](nextItem, {
|
||||
context: "Failed to construct 'File': parameter 1" + "'s element"
|
||||
});
|
||||
}
|
||||
V.push(nextItem);
|
||||
}
|
||||
curArg = V;
|
||||
}
|
||||
args.push(curArg);
|
||||
}
|
||||
{
|
||||
let curArg = arguments[1];
|
||||
curArg = conversions["USVString"](curArg, { context: "Failed to construct 'File': parameter 2" });
|
||||
args.push(curArg);
|
||||
}
|
||||
{
|
||||
let curArg = arguments[2];
|
||||
curArg = FilePropertyBag.convert(curArg, { context: "Failed to construct 'File': parameter 3" });
|
||||
args.push(curArg);
|
||||
}
|
||||
return exports.setup(Object.create(new.target.prototype), globalObject, args);
|
||||
}
|
||||
|
||||
get name() {
|
||||
const esValue = this !== null && this !== undefined ? this : globalObject;
|
||||
|
||||
if (!exports.is(esValue)) {
|
||||
throw new TypeError("Illegal invocation");
|
||||
}
|
||||
|
||||
return esValue[implSymbol]["name"];
|
||||
}
|
||||
|
||||
get lastModified() {
|
||||
const esValue = this !== null && this !== undefined ? this : globalObject;
|
||||
|
||||
if (!exports.is(esValue)) {
|
||||
throw new TypeError("Illegal invocation");
|
||||
}
|
||||
|
||||
return esValue[implSymbol]["lastModified"];
|
||||
}
|
||||
}
|
||||
Object.defineProperties(File.prototype, {
|
||||
name: { enumerable: true },
|
||||
lastModified: { enumerable: true },
|
||||
[Symbol.toStringTag]: { value: "File", configurable: true }
|
||||
});
|
||||
if (globalObject[ctorRegistrySymbol] === undefined) {
|
||||
globalObject[ctorRegistrySymbol] = Object.create(null);
|
||||
}
|
||||
globalObject[ctorRegistrySymbol][interfaceName] = File;
|
||||
|
||||
Object.defineProperty(globalObject, interfaceName, {
|
||||
configurable: true,
|
||||
writable: true,
|
||||
value: File
|
||||
});
|
||||
};
|
||||
|
||||
const Impl = require("../file-api/File-impl.js");
|
||||
|
||||
579
node_modules/jsdom/lib/jsdom/living/generated/FileList.js
generated
vendored
579
node_modules/jsdom/lib/jsdom/living/generated/FileList.js
generated
vendored
@@ -3,299 +3,302 @@
|
||||
const conversions = require("webidl-conversions");
|
||||
const utils = require("./utils.js");
|
||||
|
||||
const impl = utils.implSymbol;
|
||||
const implSymbol = utils.implSymbol;
|
||||
const ctorRegistrySymbol = utils.ctorRegistrySymbol;
|
||||
|
||||
function FileList() {
|
||||
throw new TypeError("Illegal constructor");
|
||||
}
|
||||
const interfaceName = "FileList";
|
||||
|
||||
Object.defineProperty(FileList, "prototype", {
|
||||
value: FileList.prototype,
|
||||
writable: false,
|
||||
enumerable: false,
|
||||
configurable: false
|
||||
});
|
||||
|
||||
Object.defineProperty(FileList.prototype, Symbol.iterator, {
|
||||
writable: true,
|
||||
enumerable: false,
|
||||
configurable: true,
|
||||
value: Array.prototype[Symbol.iterator]
|
||||
});
|
||||
|
||||
FileList.prototype.item = function item(index) {
|
||||
if (!this || !module.exports.is(this)) {
|
||||
throw new TypeError("Illegal invocation");
|
||||
exports.is = value => {
|
||||
return utils.isObject(value) && utils.hasOwn(value, implSymbol) && value[implSymbol] instanceof Impl.implementation;
|
||||
};
|
||||
exports.isImpl = value => {
|
||||
return utils.isObject(value) && value instanceof Impl.implementation;
|
||||
};
|
||||
exports.convert = (value, { context = "The provided value" } = {}) => {
|
||||
if (exports.is(value)) {
|
||||
return utils.implForWrapper(value);
|
||||
}
|
||||
|
||||
if (arguments.length < 1) {
|
||||
throw new TypeError(
|
||||
"Failed to execute 'item' on 'FileList': 1 argument required, but only " + arguments.length + " present."
|
||||
);
|
||||
}
|
||||
const args = [];
|
||||
{
|
||||
let curArg = arguments[0];
|
||||
curArg = conversions["unsigned long"](curArg, { context: "Failed to execute 'item' on 'FileList': parameter 1" });
|
||||
args.push(curArg);
|
||||
}
|
||||
return utils.tryWrapperForImpl(this[impl].item(...args));
|
||||
throw new TypeError(`${context} is not of type 'FileList'.`);
|
||||
};
|
||||
|
||||
Object.defineProperty(FileList.prototype, "length", {
|
||||
get() {
|
||||
if (!this || !module.exports.is(this)) {
|
||||
throw new TypeError("Illegal invocation");
|
||||
}
|
||||
|
||||
return this[impl]["length"];
|
||||
},
|
||||
|
||||
enumerable: true,
|
||||
configurable: true
|
||||
});
|
||||
|
||||
Object.defineProperty(FileList.prototype, Symbol.toStringTag, {
|
||||
value: "FileList",
|
||||
writable: false,
|
||||
enumerable: false,
|
||||
configurable: true
|
||||
});
|
||||
|
||||
const iface = {
|
||||
// When an interface-module that implements this interface as a mixin is loaded, it will append its own `.is()`
|
||||
// method into this array. It allows objects that directly implements *those* interfaces to be recognized as
|
||||
// implementing this mixin interface.
|
||||
_mixedIntoPredicates: [],
|
||||
is(obj) {
|
||||
if (obj) {
|
||||
if (utils.hasOwn(obj, impl) && obj[impl] instanceof Impl.implementation) {
|
||||
return true;
|
||||
}
|
||||
for (const isMixedInto of module.exports._mixedIntoPredicates) {
|
||||
if (isMixedInto(obj)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
},
|
||||
isImpl(obj) {
|
||||
if (obj) {
|
||||
if (obj instanceof Impl.implementation) {
|
||||
return true;
|
||||
}
|
||||
|
||||
const wrapper = utils.wrapperForImpl(obj);
|
||||
for (const isMixedInto of module.exports._mixedIntoPredicates) {
|
||||
if (isMixedInto(wrapper)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
},
|
||||
convert(obj, { context = "The provided value" } = {}) {
|
||||
if (module.exports.is(obj)) {
|
||||
return utils.implForWrapper(obj);
|
||||
}
|
||||
throw new TypeError(`${context} is not of type 'FileList'.`);
|
||||
},
|
||||
|
||||
create(constructorArgs, privateData) {
|
||||
let obj = Object.create(FileList.prototype);
|
||||
obj = this.setup(obj, constructorArgs, privateData);
|
||||
return obj;
|
||||
},
|
||||
createImpl(constructorArgs, privateData) {
|
||||
let obj = Object.create(FileList.prototype);
|
||||
obj = this.setup(obj, constructorArgs, privateData);
|
||||
return utils.implForWrapper(obj);
|
||||
},
|
||||
_internalSetup(obj) {},
|
||||
setup(obj, constructorArgs, privateData) {
|
||||
if (!privateData) privateData = {};
|
||||
|
||||
privateData.wrapper = obj;
|
||||
|
||||
this._internalSetup(obj);
|
||||
Object.defineProperty(obj, impl, {
|
||||
value: new Impl.implementation(constructorArgs, privateData),
|
||||
writable: false,
|
||||
enumerable: false,
|
||||
configurable: true
|
||||
});
|
||||
|
||||
obj = new Proxy(obj, {
|
||||
get(target, P, receiver) {
|
||||
if (typeof P === "symbol") {
|
||||
return Reflect.get(target, P, receiver);
|
||||
}
|
||||
const desc = this.getOwnPropertyDescriptor(target, P);
|
||||
if (desc === undefined) {
|
||||
const parent = Object.getPrototypeOf(target);
|
||||
if (parent === null) {
|
||||
return undefined;
|
||||
}
|
||||
return Reflect.get(target, P, receiver);
|
||||
}
|
||||
if (!desc.get && !desc.set) {
|
||||
return desc.value;
|
||||
}
|
||||
const getter = desc.get;
|
||||
if (getter === undefined) {
|
||||
return undefined;
|
||||
}
|
||||
return Reflect.apply(getter, receiver, []);
|
||||
},
|
||||
|
||||
has(target, P) {
|
||||
if (typeof P === "symbol") {
|
||||
return Reflect.has(target, P);
|
||||
}
|
||||
const desc = this.getOwnPropertyDescriptor(target, P);
|
||||
if (desc !== undefined) {
|
||||
return true;
|
||||
}
|
||||
const parent = Object.getPrototypeOf(target);
|
||||
if (parent !== null) {
|
||||
return Reflect.has(parent, P);
|
||||
}
|
||||
return false;
|
||||
},
|
||||
|
||||
ownKeys(target) {
|
||||
const keys = new Set();
|
||||
|
||||
for (const key of target[impl][utils.supportedPropertyIndices]) {
|
||||
keys.add(`${key}`);
|
||||
}
|
||||
|
||||
for (const key of Reflect.ownKeys(target)) {
|
||||
keys.add(key);
|
||||
}
|
||||
return [...keys];
|
||||
},
|
||||
|
||||
getOwnPropertyDescriptor(target, P) {
|
||||
if (typeof P === "symbol") {
|
||||
return Reflect.getOwnPropertyDescriptor(target, P);
|
||||
}
|
||||
let ignoreNamedProps = false;
|
||||
|
||||
if (utils.isArrayIndexPropName(P)) {
|
||||
const index = P >>> 0;
|
||||
const indexedValue = target[impl].item(index);
|
||||
if (indexedValue !== null) {
|
||||
return {
|
||||
writable: false,
|
||||
enumerable: true,
|
||||
configurable: true,
|
||||
value: utils.tryWrapperForImpl(indexedValue)
|
||||
};
|
||||
}
|
||||
ignoreNamedProps = true;
|
||||
}
|
||||
|
||||
return Reflect.getOwnPropertyDescriptor(target, P);
|
||||
},
|
||||
|
||||
set(target, P, V, receiver) {
|
||||
if (typeof P === "symbol") {
|
||||
return Reflect.set(target, P, V, receiver);
|
||||
}
|
||||
if (target === receiver) {
|
||||
utils.isArrayIndexPropName(P);
|
||||
}
|
||||
let ownDesc;
|
||||
|
||||
if (utils.isArrayIndexPropName(P)) {
|
||||
const index = P >>> 0;
|
||||
const indexedValue = target[impl].item(index);
|
||||
if (indexedValue !== null) {
|
||||
ownDesc = {
|
||||
writable: false,
|
||||
enumerable: true,
|
||||
configurable: true,
|
||||
value: utils.tryWrapperForImpl(indexedValue)
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
if (ownDesc === undefined) {
|
||||
ownDesc = Reflect.getOwnPropertyDescriptor(target, P);
|
||||
}
|
||||
if (ownDesc === undefined) {
|
||||
const parent = Reflect.getPrototypeOf(target);
|
||||
if (parent !== null) {
|
||||
return Reflect.set(parent, P, V, receiver);
|
||||
}
|
||||
ownDesc = { writable: true, enumerable: true, configurable: true, value: undefined };
|
||||
}
|
||||
if (!ownDesc.writable) {
|
||||
return false;
|
||||
}
|
||||
if (!utils.isObject(receiver)) {
|
||||
return false;
|
||||
}
|
||||
const existingDesc = Reflect.getOwnPropertyDescriptor(receiver, P);
|
||||
let valueDesc;
|
||||
if (existingDesc !== undefined) {
|
||||
if (existingDesc.get || existingDesc.set) {
|
||||
return false;
|
||||
}
|
||||
if (!existingDesc.writable) {
|
||||
return false;
|
||||
}
|
||||
valueDesc = { value: V };
|
||||
} else {
|
||||
valueDesc = { writable: true, enumerable: true, configurable: true, value: V };
|
||||
}
|
||||
return Reflect.defineProperty(receiver, P, valueDesc);
|
||||
},
|
||||
|
||||
defineProperty(target, P, desc) {
|
||||
if (typeof P === "symbol") {
|
||||
return Reflect.defineProperty(target, P, desc);
|
||||
}
|
||||
|
||||
if (utils.isArrayIndexPropName(P)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return Reflect.defineProperty(target, P, desc);
|
||||
},
|
||||
|
||||
deleteProperty(target, P) {
|
||||
if (typeof P === "symbol") {
|
||||
return Reflect.deleteProperty(target, P);
|
||||
}
|
||||
|
||||
if (utils.isArrayIndexPropName(P)) {
|
||||
const index = P >>> 0;
|
||||
return !(target[impl].item(index) !== null);
|
||||
}
|
||||
|
||||
return Reflect.deleteProperty(target, P);
|
||||
},
|
||||
|
||||
preventExtensions() {
|
||||
return false;
|
||||
}
|
||||
});
|
||||
|
||||
obj[impl][utils.wrapperSymbol] = obj;
|
||||
if (Impl.init) {
|
||||
Impl.init(obj[impl], privateData);
|
||||
}
|
||||
return obj;
|
||||
},
|
||||
interface: FileList,
|
||||
expose: {
|
||||
Window: { FileList },
|
||||
Worker: { FileList }
|
||||
function makeWrapper(globalObject) {
|
||||
if (globalObject[ctorRegistrySymbol] === undefined) {
|
||||
throw new Error("Internal error: invalid global object");
|
||||
}
|
||||
}; // iface
|
||||
module.exports = iface;
|
||||
|
||||
const ctor = globalObject[ctorRegistrySymbol]["FileList"];
|
||||
if (ctor === undefined) {
|
||||
throw new Error("Internal error: constructor FileList is not installed on the passed global object");
|
||||
}
|
||||
|
||||
return Object.create(ctor.prototype);
|
||||
}
|
||||
|
||||
exports.create = (globalObject, constructorArgs, privateData) => {
|
||||
const wrapper = makeWrapper(globalObject);
|
||||
return exports.setup(wrapper, globalObject, constructorArgs, privateData);
|
||||
};
|
||||
|
||||
exports.createImpl = (globalObject, constructorArgs, privateData) => {
|
||||
const wrapper = exports.create(globalObject, constructorArgs, privateData);
|
||||
return utils.implForWrapper(wrapper);
|
||||
};
|
||||
|
||||
exports._internalSetup = (wrapper, globalObject) => {};
|
||||
|
||||
exports.setup = (wrapper, globalObject, constructorArgs = [], privateData = {}) => {
|
||||
privateData.wrapper = wrapper;
|
||||
|
||||
exports._internalSetup(wrapper, globalObject);
|
||||
Object.defineProperty(wrapper, implSymbol, {
|
||||
value: new Impl.implementation(globalObject, constructorArgs, privateData),
|
||||
configurable: true
|
||||
});
|
||||
|
||||
wrapper = new Proxy(wrapper, proxyHandler);
|
||||
|
||||
wrapper[implSymbol][utils.wrapperSymbol] = wrapper;
|
||||
if (Impl.init) {
|
||||
Impl.init(wrapper[implSymbol]);
|
||||
}
|
||||
return wrapper;
|
||||
};
|
||||
|
||||
exports.new = globalObject => {
|
||||
let wrapper = makeWrapper(globalObject);
|
||||
|
||||
exports._internalSetup(wrapper, globalObject);
|
||||
Object.defineProperty(wrapper, implSymbol, {
|
||||
value: Object.create(Impl.implementation.prototype),
|
||||
configurable: true
|
||||
});
|
||||
|
||||
wrapper = new Proxy(wrapper, proxyHandler);
|
||||
|
||||
wrapper[implSymbol][utils.wrapperSymbol] = wrapper;
|
||||
if (Impl.init) {
|
||||
Impl.init(wrapper[implSymbol]);
|
||||
}
|
||||
return wrapper[implSymbol];
|
||||
};
|
||||
|
||||
const exposed = new Set(["Window", "Worker"]);
|
||||
|
||||
exports.install = (globalObject, globalNames) => {
|
||||
if (!globalNames.some(globalName => exposed.has(globalName))) {
|
||||
return;
|
||||
}
|
||||
class FileList {
|
||||
constructor() {
|
||||
throw new TypeError("Illegal constructor");
|
||||
}
|
||||
|
||||
item(index) {
|
||||
const esValue = this !== null && this !== undefined ? this : globalObject;
|
||||
if (!exports.is(esValue)) {
|
||||
throw new TypeError("Illegal invocation");
|
||||
}
|
||||
|
||||
if (arguments.length < 1) {
|
||||
throw new TypeError(
|
||||
"Failed to execute 'item' on 'FileList': 1 argument required, but only " + arguments.length + " present."
|
||||
);
|
||||
}
|
||||
const args = [];
|
||||
{
|
||||
let curArg = arguments[0];
|
||||
curArg = conversions["unsigned long"](curArg, {
|
||||
context: "Failed to execute 'item' on 'FileList': parameter 1"
|
||||
});
|
||||
args.push(curArg);
|
||||
}
|
||||
return utils.tryWrapperForImpl(esValue[implSymbol].item(...args));
|
||||
}
|
||||
|
||||
get length() {
|
||||
const esValue = this !== null && this !== undefined ? this : globalObject;
|
||||
|
||||
if (!exports.is(esValue)) {
|
||||
throw new TypeError("Illegal invocation");
|
||||
}
|
||||
|
||||
return esValue[implSymbol]["length"];
|
||||
}
|
||||
}
|
||||
Object.defineProperties(FileList.prototype, {
|
||||
item: { enumerable: true },
|
||||
length: { enumerable: true },
|
||||
[Symbol.toStringTag]: { value: "FileList", configurable: true },
|
||||
[Symbol.iterator]: { value: Array.prototype[Symbol.iterator], configurable: true, writable: true }
|
||||
});
|
||||
if (globalObject[ctorRegistrySymbol] === undefined) {
|
||||
globalObject[ctorRegistrySymbol] = Object.create(null);
|
||||
}
|
||||
globalObject[ctorRegistrySymbol][interfaceName] = FileList;
|
||||
|
||||
Object.defineProperty(globalObject, interfaceName, {
|
||||
configurable: true,
|
||||
writable: true,
|
||||
value: FileList
|
||||
});
|
||||
};
|
||||
|
||||
const proxyHandler = {
|
||||
get(target, P, receiver) {
|
||||
if (typeof P === "symbol") {
|
||||
return Reflect.get(target, P, receiver);
|
||||
}
|
||||
const desc = this.getOwnPropertyDescriptor(target, P);
|
||||
if (desc === undefined) {
|
||||
const parent = Object.getPrototypeOf(target);
|
||||
if (parent === null) {
|
||||
return undefined;
|
||||
}
|
||||
return Reflect.get(target, P, receiver);
|
||||
}
|
||||
if (!desc.get && !desc.set) {
|
||||
return desc.value;
|
||||
}
|
||||
const getter = desc.get;
|
||||
if (getter === undefined) {
|
||||
return undefined;
|
||||
}
|
||||
return Reflect.apply(getter, receiver, []);
|
||||
},
|
||||
|
||||
has(target, P) {
|
||||
if (typeof P === "symbol") {
|
||||
return Reflect.has(target, P);
|
||||
}
|
||||
const desc = this.getOwnPropertyDescriptor(target, P);
|
||||
if (desc !== undefined) {
|
||||
return true;
|
||||
}
|
||||
const parent = Object.getPrototypeOf(target);
|
||||
if (parent !== null) {
|
||||
return Reflect.has(parent, P);
|
||||
}
|
||||
return false;
|
||||
},
|
||||
|
||||
ownKeys(target) {
|
||||
const keys = new Set();
|
||||
|
||||
for (const key of target[implSymbol][utils.supportedPropertyIndices]) {
|
||||
keys.add(`${key}`);
|
||||
}
|
||||
|
||||
for (const key of Reflect.ownKeys(target)) {
|
||||
keys.add(key);
|
||||
}
|
||||
return [...keys];
|
||||
},
|
||||
|
||||
getOwnPropertyDescriptor(target, P) {
|
||||
if (typeof P === "symbol") {
|
||||
return Reflect.getOwnPropertyDescriptor(target, P);
|
||||
}
|
||||
let ignoreNamedProps = false;
|
||||
|
||||
if (utils.isArrayIndexPropName(P)) {
|
||||
const index = P >>> 0;
|
||||
const indexedValue = target[implSymbol].item(index);
|
||||
if (indexedValue !== null) {
|
||||
return {
|
||||
writable: false,
|
||||
enumerable: true,
|
||||
configurable: true,
|
||||
value: utils.tryWrapperForImpl(indexedValue)
|
||||
};
|
||||
}
|
||||
ignoreNamedProps = true;
|
||||
}
|
||||
|
||||
return Reflect.getOwnPropertyDescriptor(target, P);
|
||||
},
|
||||
|
||||
set(target, P, V, receiver) {
|
||||
if (typeof P === "symbol") {
|
||||
return Reflect.set(target, P, V, receiver);
|
||||
}
|
||||
if (target === receiver) {
|
||||
utils.isArrayIndexPropName(P);
|
||||
}
|
||||
let ownDesc;
|
||||
|
||||
if (utils.isArrayIndexPropName(P)) {
|
||||
const index = P >>> 0;
|
||||
const indexedValue = target[implSymbol].item(index);
|
||||
if (indexedValue !== null) {
|
||||
ownDesc = {
|
||||
writable: false,
|
||||
enumerable: true,
|
||||
configurable: true,
|
||||
value: utils.tryWrapperForImpl(indexedValue)
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
if (ownDesc === undefined) {
|
||||
ownDesc = Reflect.getOwnPropertyDescriptor(target, P);
|
||||
}
|
||||
if (ownDesc === undefined) {
|
||||
const parent = Reflect.getPrototypeOf(target);
|
||||
if (parent !== null) {
|
||||
return Reflect.set(parent, P, V, receiver);
|
||||
}
|
||||
ownDesc = { writable: true, enumerable: true, configurable: true, value: undefined };
|
||||
}
|
||||
if (!ownDesc.writable) {
|
||||
return false;
|
||||
}
|
||||
if (!utils.isObject(receiver)) {
|
||||
return false;
|
||||
}
|
||||
const existingDesc = Reflect.getOwnPropertyDescriptor(receiver, P);
|
||||
let valueDesc;
|
||||
if (existingDesc !== undefined) {
|
||||
if (existingDesc.get || existingDesc.set) {
|
||||
return false;
|
||||
}
|
||||
if (!existingDesc.writable) {
|
||||
return false;
|
||||
}
|
||||
valueDesc = { value: V };
|
||||
} else {
|
||||
valueDesc = { writable: true, enumerable: true, configurable: true, value: V };
|
||||
}
|
||||
return Reflect.defineProperty(receiver, P, valueDesc);
|
||||
},
|
||||
|
||||
defineProperty(target, P, desc) {
|
||||
if (typeof P === "symbol") {
|
||||
return Reflect.defineProperty(target, P, desc);
|
||||
}
|
||||
|
||||
if (utils.isArrayIndexPropName(P)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return Reflect.defineProperty(target, P, desc);
|
||||
},
|
||||
|
||||
deleteProperty(target, P) {
|
||||
if (typeof P === "symbol") {
|
||||
return Reflect.deleteProperty(target, P);
|
||||
}
|
||||
|
||||
if (utils.isArrayIndexPropName(P)) {
|
||||
const index = P >>> 0;
|
||||
return !(target[implSymbol].item(index) !== null);
|
||||
}
|
||||
|
||||
return Reflect.deleteProperty(target, P);
|
||||
},
|
||||
|
||||
preventExtensions() {
|
||||
return false;
|
||||
}
|
||||
};
|
||||
|
||||
const Impl = require("../file-api/FileList-impl.js");
|
||||
|
||||
38
node_modules/jsdom/lib/jsdom/living/generated/FilePropertyBag.js
generated
vendored
38
node_modules/jsdom/lib/jsdom/living/generated/FilePropertyBag.js
generated
vendored
@@ -5,28 +5,26 @@ const utils = require("./utils.js");
|
||||
|
||||
const BlobPropertyBag = require("./BlobPropertyBag.js");
|
||||
|
||||
module.exports = {
|
||||
convertInherit(obj, ret, { context = "The provided value" } = {}) {
|
||||
BlobPropertyBag.convertInherit(obj, ret, { context });
|
||||
exports._convertInherit = (obj, ret, { context = "The provided value" } = {}) => {
|
||||
BlobPropertyBag._convertInherit(obj, ret, { context });
|
||||
|
||||
{
|
||||
const key = "lastModified";
|
||||
let value = obj === undefined || obj === null ? undefined : obj[key];
|
||||
if (value !== undefined) {
|
||||
value = conversions["long long"](value, { context: context + " has member lastModified that" });
|
||||
{
|
||||
const key = "lastModified";
|
||||
let value = obj === undefined || obj === null ? undefined : obj[key];
|
||||
if (value !== undefined) {
|
||||
value = conversions["long long"](value, { context: context + " has member 'lastModified' that" });
|
||||
|
||||
ret[key] = value;
|
||||
}
|
||||
ret[key] = value;
|
||||
}
|
||||
},
|
||||
|
||||
convert(obj, { context = "The provided value" } = {}) {
|
||||
if (obj !== undefined && typeof obj !== "object" && typeof obj !== "function") {
|
||||
throw new TypeError(`${context} is not an object.`);
|
||||
}
|
||||
|
||||
const ret = Object.create(null);
|
||||
module.exports.convertInherit(obj, ret, { context });
|
||||
return ret;
|
||||
}
|
||||
};
|
||||
|
||||
exports.convert = function convert(obj, { context = "The provided value" } = {}) {
|
||||
if (obj !== undefined && typeof obj !== "object" && typeof obj !== "function") {
|
||||
throw new TypeError(`${context} is not an object.`);
|
||||
}
|
||||
|
||||
const ret = Object.create(null);
|
||||
exports._convertInherit(obj, ret, { context });
|
||||
return ret;
|
||||
};
|
||||
|
||||
650
node_modules/jsdom/lib/jsdom/living/generated/FileReader.js
generated
vendored
650
node_modules/jsdom/lib/jsdom/living/generated/FileReader.js
generated
vendored
@@ -3,35 +3,103 @@
|
||||
const conversions = require("webidl-conversions");
|
||||
const utils = require("./utils.js");
|
||||
|
||||
const convertBlob = require("./Blob.js").convert;
|
||||
const impl = utils.implSymbol;
|
||||
const Blob = require("./Blob.js");
|
||||
const implSymbol = utils.implSymbol;
|
||||
const ctorRegistrySymbol = utils.ctorRegistrySymbol;
|
||||
const EventTarget = require("./EventTarget.js");
|
||||
|
||||
module.exports = {
|
||||
createInterface: function(defaultPrivateData = {}) {
|
||||
function FileReader() {
|
||||
if (new.target === undefined) {
|
||||
throw new TypeError(
|
||||
"Failed to construct 'FileReader'. Please use the 'new' operator; this constructor " +
|
||||
"cannot be called as a function."
|
||||
);
|
||||
}
|
||||
const interfaceName = "FileReader";
|
||||
|
||||
iface.setup(this);
|
||||
exports.is = value => {
|
||||
return utils.isObject(value) && utils.hasOwn(value, implSymbol) && value[implSymbol] instanceof Impl.implementation;
|
||||
};
|
||||
exports.isImpl = value => {
|
||||
return utils.isObject(value) && value instanceof Impl.implementation;
|
||||
};
|
||||
exports.convert = (value, { context = "The provided value" } = {}) => {
|
||||
if (exports.is(value)) {
|
||||
return utils.implForWrapper(value);
|
||||
}
|
||||
throw new TypeError(`${context} is not of type 'FileReader'.`);
|
||||
};
|
||||
|
||||
function makeWrapper(globalObject) {
|
||||
if (globalObject[ctorRegistrySymbol] === undefined) {
|
||||
throw new Error("Internal error: invalid global object");
|
||||
}
|
||||
|
||||
const ctor = globalObject[ctorRegistrySymbol]["FileReader"];
|
||||
if (ctor === undefined) {
|
||||
throw new Error("Internal error: constructor FileReader is not installed on the passed global object");
|
||||
}
|
||||
|
||||
return Object.create(ctor.prototype);
|
||||
}
|
||||
|
||||
exports.create = (globalObject, constructorArgs, privateData) => {
|
||||
const wrapper = makeWrapper(globalObject);
|
||||
return exports.setup(wrapper, globalObject, constructorArgs, privateData);
|
||||
};
|
||||
|
||||
exports.createImpl = (globalObject, constructorArgs, privateData) => {
|
||||
const wrapper = exports.create(globalObject, constructorArgs, privateData);
|
||||
return utils.implForWrapper(wrapper);
|
||||
};
|
||||
|
||||
exports._internalSetup = (wrapper, globalObject) => {
|
||||
EventTarget._internalSetup(wrapper, globalObject);
|
||||
};
|
||||
|
||||
exports.setup = (wrapper, globalObject, constructorArgs = [], privateData = {}) => {
|
||||
privateData.wrapper = wrapper;
|
||||
|
||||
exports._internalSetup(wrapper, globalObject);
|
||||
Object.defineProperty(wrapper, implSymbol, {
|
||||
value: new Impl.implementation(globalObject, constructorArgs, privateData),
|
||||
configurable: true
|
||||
});
|
||||
|
||||
wrapper[implSymbol][utils.wrapperSymbol] = wrapper;
|
||||
if (Impl.init) {
|
||||
Impl.init(wrapper[implSymbol]);
|
||||
}
|
||||
return wrapper;
|
||||
};
|
||||
|
||||
exports.new = globalObject => {
|
||||
const wrapper = makeWrapper(globalObject);
|
||||
|
||||
exports._internalSetup(wrapper, globalObject);
|
||||
Object.defineProperty(wrapper, implSymbol, {
|
||||
value: Object.create(Impl.implementation.prototype),
|
||||
configurable: true
|
||||
});
|
||||
|
||||
wrapper[implSymbol][utils.wrapperSymbol] = wrapper;
|
||||
if (Impl.init) {
|
||||
Impl.init(wrapper[implSymbol]);
|
||||
}
|
||||
return wrapper[implSymbol];
|
||||
};
|
||||
|
||||
const exposed = new Set(["Window", "Worker"]);
|
||||
|
||||
exports.install = (globalObject, globalNames) => {
|
||||
if (!globalNames.some(globalName => exposed.has(globalName))) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (globalObject.EventTarget === undefined) {
|
||||
throw new Error("Internal error: attempting to evaluate FileReader before EventTarget");
|
||||
}
|
||||
class FileReader extends globalObject.EventTarget {
|
||||
constructor() {
|
||||
return exports.setup(Object.create(new.target.prototype), globalObject, undefined);
|
||||
}
|
||||
|
||||
Object.setPrototypeOf(FileReader.prototype, EventTarget.interface.prototype);
|
||||
Object.setPrototypeOf(FileReader, EventTarget.interface);
|
||||
|
||||
Object.defineProperty(FileReader, "prototype", {
|
||||
value: FileReader.prototype,
|
||||
writable: false,
|
||||
enumerable: false,
|
||||
configurable: false
|
||||
});
|
||||
|
||||
FileReader.prototype.readAsArrayBuffer = function readAsArrayBuffer(blob) {
|
||||
if (!this || !module.exports.is(this)) {
|
||||
readAsArrayBuffer(blob) {
|
||||
const esValue = this !== null && this !== undefined ? this : globalObject;
|
||||
if (!exports.is(esValue)) {
|
||||
throw new TypeError("Illegal invocation");
|
||||
}
|
||||
|
||||
@@ -45,14 +113,17 @@ module.exports = {
|
||||
const args = [];
|
||||
{
|
||||
let curArg = arguments[0];
|
||||
curArg = convertBlob(curArg, { context: "Failed to execute 'readAsArrayBuffer' on 'FileReader': parameter 1" });
|
||||
curArg = Blob.convert(curArg, {
|
||||
context: "Failed to execute 'readAsArrayBuffer' on 'FileReader': parameter 1"
|
||||
});
|
||||
args.push(curArg);
|
||||
}
|
||||
return this[impl].readAsArrayBuffer(...args);
|
||||
};
|
||||
return esValue[implSymbol].readAsArrayBuffer(...args);
|
||||
}
|
||||
|
||||
FileReader.prototype.readAsBinaryString = function readAsBinaryString(blob) {
|
||||
if (!this || !module.exports.is(this)) {
|
||||
readAsBinaryString(blob) {
|
||||
const esValue = this !== null && this !== undefined ? this : globalObject;
|
||||
if (!exports.is(esValue)) {
|
||||
throw new TypeError("Illegal invocation");
|
||||
}
|
||||
|
||||
@@ -66,16 +137,17 @@ module.exports = {
|
||||
const args = [];
|
||||
{
|
||||
let curArg = arguments[0];
|
||||
curArg = convertBlob(curArg, {
|
||||
curArg = Blob.convert(curArg, {
|
||||
context: "Failed to execute 'readAsBinaryString' on 'FileReader': parameter 1"
|
||||
});
|
||||
args.push(curArg);
|
||||
}
|
||||
return this[impl].readAsBinaryString(...args);
|
||||
};
|
||||
return esValue[implSymbol].readAsBinaryString(...args);
|
||||
}
|
||||
|
||||
FileReader.prototype.readAsText = function readAsText(blob) {
|
||||
if (!this || !module.exports.is(this)) {
|
||||
readAsText(blob) {
|
||||
const esValue = this !== null && this !== undefined ? this : globalObject;
|
||||
if (!exports.is(esValue)) {
|
||||
throw new TypeError("Illegal invocation");
|
||||
}
|
||||
|
||||
@@ -89,7 +161,7 @@ module.exports = {
|
||||
const args = [];
|
||||
{
|
||||
let curArg = arguments[0];
|
||||
curArg = convertBlob(curArg, { context: "Failed to execute 'readAsText' on 'FileReader': parameter 1" });
|
||||
curArg = Blob.convert(curArg, { context: "Failed to execute 'readAsText' on 'FileReader': parameter 1" });
|
||||
args.push(curArg);
|
||||
}
|
||||
{
|
||||
@@ -101,11 +173,12 @@ module.exports = {
|
||||
}
|
||||
args.push(curArg);
|
||||
}
|
||||
return this[impl].readAsText(...args);
|
||||
};
|
||||
return esValue[implSymbol].readAsText(...args);
|
||||
}
|
||||
|
||||
FileReader.prototype.readAsDataURL = function readAsDataURL(blob) {
|
||||
if (!this || !module.exports.is(this)) {
|
||||
readAsDataURL(blob) {
|
||||
const esValue = this !== null && this !== undefined ? this : globalObject;
|
||||
if (!exports.is(esValue)) {
|
||||
throw new TypeError("Illegal invocation");
|
||||
}
|
||||
|
||||
@@ -119,317 +192,218 @@ module.exports = {
|
||||
const args = [];
|
||||
{
|
||||
let curArg = arguments[0];
|
||||
curArg = convertBlob(curArg, { context: "Failed to execute 'readAsDataURL' on 'FileReader': parameter 1" });
|
||||
curArg = Blob.convert(curArg, { context: "Failed to execute 'readAsDataURL' on 'FileReader': parameter 1" });
|
||||
args.push(curArg);
|
||||
}
|
||||
return this[impl].readAsDataURL(...args);
|
||||
};
|
||||
return esValue[implSymbol].readAsDataURL(...args);
|
||||
}
|
||||
|
||||
FileReader.prototype.abort = function abort() {
|
||||
if (!this || !module.exports.is(this)) {
|
||||
abort() {
|
||||
const esValue = this !== null && this !== undefined ? this : globalObject;
|
||||
if (!exports.is(esValue)) {
|
||||
throw new TypeError("Illegal invocation");
|
||||
}
|
||||
|
||||
return this[impl].abort();
|
||||
};
|
||||
|
||||
Object.defineProperty(FileReader.prototype, "readyState", {
|
||||
get() {
|
||||
if (!this || !module.exports.is(this)) {
|
||||
throw new TypeError("Illegal invocation");
|
||||
}
|
||||
|
||||
return this[impl]["readyState"];
|
||||
},
|
||||
|
||||
enumerable: true,
|
||||
configurable: true
|
||||
});
|
||||
|
||||
Object.defineProperty(FileReader.prototype, "result", {
|
||||
get() {
|
||||
if (!this || !module.exports.is(this)) {
|
||||
throw new TypeError("Illegal invocation");
|
||||
}
|
||||
|
||||
return utils.tryWrapperForImpl(this[impl]["result"]);
|
||||
},
|
||||
|
||||
enumerable: true,
|
||||
configurable: true
|
||||
});
|
||||
|
||||
Object.defineProperty(FileReader.prototype, "error", {
|
||||
get() {
|
||||
if (!this || !module.exports.is(this)) {
|
||||
throw new TypeError("Illegal invocation");
|
||||
}
|
||||
|
||||
return utils.tryWrapperForImpl(this[impl]["error"]);
|
||||
},
|
||||
|
||||
enumerable: true,
|
||||
configurable: true
|
||||
});
|
||||
|
||||
Object.defineProperty(FileReader.prototype, "onloadstart", {
|
||||
get() {
|
||||
if (!this || !module.exports.is(this)) {
|
||||
throw new TypeError("Illegal invocation");
|
||||
}
|
||||
|
||||
return utils.tryWrapperForImpl(this[impl]["onloadstart"]);
|
||||
},
|
||||
|
||||
set(V) {
|
||||
if (!this || !module.exports.is(this)) {
|
||||
throw new TypeError("Illegal invocation");
|
||||
}
|
||||
|
||||
V = utils.tryImplForWrapper(V);
|
||||
|
||||
this[impl]["onloadstart"] = V;
|
||||
},
|
||||
|
||||
enumerable: true,
|
||||
configurable: true
|
||||
});
|
||||
|
||||
Object.defineProperty(FileReader.prototype, "onprogress", {
|
||||
get() {
|
||||
if (!this || !module.exports.is(this)) {
|
||||
throw new TypeError("Illegal invocation");
|
||||
}
|
||||
|
||||
return utils.tryWrapperForImpl(this[impl]["onprogress"]);
|
||||
},
|
||||
|
||||
set(V) {
|
||||
if (!this || !module.exports.is(this)) {
|
||||
throw new TypeError("Illegal invocation");
|
||||
}
|
||||
|
||||
V = utils.tryImplForWrapper(V);
|
||||
|
||||
this[impl]["onprogress"] = V;
|
||||
},
|
||||
|
||||
enumerable: true,
|
||||
configurable: true
|
||||
});
|
||||
|
||||
Object.defineProperty(FileReader.prototype, "onload", {
|
||||
get() {
|
||||
if (!this || !module.exports.is(this)) {
|
||||
throw new TypeError("Illegal invocation");
|
||||
}
|
||||
|
||||
return utils.tryWrapperForImpl(this[impl]["onload"]);
|
||||
},
|
||||
|
||||
set(V) {
|
||||
if (!this || !module.exports.is(this)) {
|
||||
throw new TypeError("Illegal invocation");
|
||||
}
|
||||
|
||||
V = utils.tryImplForWrapper(V);
|
||||
|
||||
this[impl]["onload"] = V;
|
||||
},
|
||||
|
||||
enumerable: true,
|
||||
configurable: true
|
||||
});
|
||||
|
||||
Object.defineProperty(FileReader.prototype, "onabort", {
|
||||
get() {
|
||||
if (!this || !module.exports.is(this)) {
|
||||
throw new TypeError("Illegal invocation");
|
||||
}
|
||||
|
||||
return utils.tryWrapperForImpl(this[impl]["onabort"]);
|
||||
},
|
||||
|
||||
set(V) {
|
||||
if (!this || !module.exports.is(this)) {
|
||||
throw new TypeError("Illegal invocation");
|
||||
}
|
||||
|
||||
V = utils.tryImplForWrapper(V);
|
||||
|
||||
this[impl]["onabort"] = V;
|
||||
},
|
||||
|
||||
enumerable: true,
|
||||
configurable: true
|
||||
});
|
||||
|
||||
Object.defineProperty(FileReader.prototype, "onerror", {
|
||||
get() {
|
||||
if (!this || !module.exports.is(this)) {
|
||||
throw new TypeError("Illegal invocation");
|
||||
}
|
||||
|
||||
return utils.tryWrapperForImpl(this[impl]["onerror"]);
|
||||
},
|
||||
|
||||
set(V) {
|
||||
if (!this || !module.exports.is(this)) {
|
||||
throw new TypeError("Illegal invocation");
|
||||
}
|
||||
|
||||
V = utils.tryImplForWrapper(V);
|
||||
|
||||
this[impl]["onerror"] = V;
|
||||
},
|
||||
|
||||
enumerable: true,
|
||||
configurable: true
|
||||
});
|
||||
|
||||
Object.defineProperty(FileReader.prototype, "onloadend", {
|
||||
get() {
|
||||
if (!this || !module.exports.is(this)) {
|
||||
throw new TypeError("Illegal invocation");
|
||||
}
|
||||
|
||||
return utils.tryWrapperForImpl(this[impl]["onloadend"]);
|
||||
},
|
||||
|
||||
set(V) {
|
||||
if (!this || !module.exports.is(this)) {
|
||||
throw new TypeError("Illegal invocation");
|
||||
}
|
||||
|
||||
V = utils.tryImplForWrapper(V);
|
||||
|
||||
this[impl]["onloadend"] = V;
|
||||
},
|
||||
|
||||
enumerable: true,
|
||||
configurable: true
|
||||
});
|
||||
|
||||
Object.defineProperty(FileReader, "EMPTY", {
|
||||
value: 0,
|
||||
enumerable: true
|
||||
});
|
||||
Object.defineProperty(FileReader.prototype, "EMPTY", {
|
||||
value: 0,
|
||||
enumerable: true
|
||||
});
|
||||
|
||||
Object.defineProperty(FileReader, "LOADING", {
|
||||
value: 1,
|
||||
enumerable: true
|
||||
});
|
||||
Object.defineProperty(FileReader.prototype, "LOADING", {
|
||||
value: 1,
|
||||
enumerable: true
|
||||
});
|
||||
|
||||
Object.defineProperty(FileReader, "DONE", {
|
||||
value: 2,
|
||||
enumerable: true
|
||||
});
|
||||
Object.defineProperty(FileReader.prototype, "DONE", {
|
||||
value: 2,
|
||||
enumerable: true
|
||||
});
|
||||
|
||||
Object.defineProperty(FileReader.prototype, Symbol.toStringTag, {
|
||||
value: "FileReader",
|
||||
writable: false,
|
||||
enumerable: false,
|
||||
configurable: true
|
||||
});
|
||||
|
||||
const iface = {
|
||||
create(constructorArgs, privateData) {
|
||||
let obj = Object.create(FileReader.prototype);
|
||||
obj = this.setup(obj, constructorArgs, privateData);
|
||||
return obj;
|
||||
},
|
||||
createImpl(constructorArgs, privateData) {
|
||||
let obj = Object.create(FileReader.prototype);
|
||||
obj = this.setup(obj, constructorArgs, privateData);
|
||||
return utils.implForWrapper(obj);
|
||||
},
|
||||
_internalSetup(obj) {
|
||||
EventTarget._internalSetup(obj);
|
||||
},
|
||||
setup(obj, constructorArgs, privateData) {
|
||||
if (!privateData) privateData = {};
|
||||
|
||||
for (var prop in defaultPrivateData) {
|
||||
if (!(prop in privateData)) {
|
||||
privateData[prop] = defaultPrivateData[prop];
|
||||
}
|
||||
}
|
||||
|
||||
privateData.wrapper = obj;
|
||||
|
||||
this._internalSetup(obj);
|
||||
Object.defineProperty(obj, impl, {
|
||||
value: new Impl.implementation(constructorArgs, privateData),
|
||||
writable: false,
|
||||
enumerable: false,
|
||||
configurable: true
|
||||
});
|
||||
|
||||
obj[impl][utils.wrapperSymbol] = obj;
|
||||
if (Impl.init) {
|
||||
Impl.init(obj[impl], privateData);
|
||||
}
|
||||
return obj;
|
||||
},
|
||||
interface: FileReader,
|
||||
expose: {
|
||||
Window: { FileReader },
|
||||
Worker: { FileReader }
|
||||
}
|
||||
}; // iface
|
||||
return iface;
|
||||
}, // createInterface
|
||||
|
||||
// When an interface-module that implements this interface as a mixin is loaded, it will append its own `.is()`
|
||||
// method into this array. It allows objects that directly implements *those* interfaces to be recognized as
|
||||
// implementing this mixin interface.
|
||||
_mixedIntoPredicates: [],
|
||||
is(obj) {
|
||||
if (obj) {
|
||||
if (utils.hasOwn(obj, impl) && obj[impl] instanceof Impl.implementation) {
|
||||
return true;
|
||||
}
|
||||
for (const isMixedInto of module.exports._mixedIntoPredicates) {
|
||||
if (isMixedInto(obj)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return esValue[implSymbol].abort();
|
||||
}
|
||||
return false;
|
||||
},
|
||||
isImpl(obj) {
|
||||
if (obj) {
|
||||
if (obj instanceof Impl.implementation) {
|
||||
return true;
|
||||
|
||||
get readyState() {
|
||||
const esValue = this !== null && this !== undefined ? this : globalObject;
|
||||
|
||||
if (!exports.is(esValue)) {
|
||||
throw new TypeError("Illegal invocation");
|
||||
}
|
||||
|
||||
const wrapper = utils.wrapperForImpl(obj);
|
||||
for (const isMixedInto of module.exports._mixedIntoPredicates) {
|
||||
if (isMixedInto(wrapper)) {
|
||||
return true;
|
||||
}
|
||||
return esValue[implSymbol]["readyState"];
|
||||
}
|
||||
|
||||
get result() {
|
||||
const esValue = this !== null && this !== undefined ? this : globalObject;
|
||||
|
||||
if (!exports.is(esValue)) {
|
||||
throw new TypeError("Illegal invocation");
|
||||
}
|
||||
|
||||
return utils.tryWrapperForImpl(esValue[implSymbol]["result"]);
|
||||
}
|
||||
return false;
|
||||
},
|
||||
convert(obj, { context = "The provided value" } = {}) {
|
||||
if (module.exports.is(obj)) {
|
||||
return utils.implForWrapper(obj);
|
||||
|
||||
get error() {
|
||||
const esValue = this !== null && this !== undefined ? this : globalObject;
|
||||
|
||||
if (!exports.is(esValue)) {
|
||||
throw new TypeError("Illegal invocation");
|
||||
}
|
||||
|
||||
return utils.tryWrapperForImpl(esValue[implSymbol]["error"]);
|
||||
}
|
||||
|
||||
get onloadstart() {
|
||||
const esValue = this !== null && this !== undefined ? this : globalObject;
|
||||
|
||||
if (!exports.is(esValue)) {
|
||||
throw new TypeError("Illegal invocation");
|
||||
}
|
||||
|
||||
return utils.tryWrapperForImpl(esValue[implSymbol]["onloadstart"]);
|
||||
}
|
||||
|
||||
set onloadstart(V) {
|
||||
const esValue = this !== null && this !== undefined ? this : globalObject;
|
||||
|
||||
if (!exports.is(esValue)) {
|
||||
throw new TypeError("Illegal invocation");
|
||||
}
|
||||
|
||||
V = utils.tryImplForWrapper(V);
|
||||
|
||||
esValue[implSymbol]["onloadstart"] = V;
|
||||
}
|
||||
|
||||
get onprogress() {
|
||||
const esValue = this !== null && this !== undefined ? this : globalObject;
|
||||
|
||||
if (!exports.is(esValue)) {
|
||||
throw new TypeError("Illegal invocation");
|
||||
}
|
||||
|
||||
return utils.tryWrapperForImpl(esValue[implSymbol]["onprogress"]);
|
||||
}
|
||||
|
||||
set onprogress(V) {
|
||||
const esValue = this !== null && this !== undefined ? this : globalObject;
|
||||
|
||||
if (!exports.is(esValue)) {
|
||||
throw new TypeError("Illegal invocation");
|
||||
}
|
||||
|
||||
V = utils.tryImplForWrapper(V);
|
||||
|
||||
esValue[implSymbol]["onprogress"] = V;
|
||||
}
|
||||
|
||||
get onload() {
|
||||
const esValue = this !== null && this !== undefined ? this : globalObject;
|
||||
|
||||
if (!exports.is(esValue)) {
|
||||
throw new TypeError("Illegal invocation");
|
||||
}
|
||||
|
||||
return utils.tryWrapperForImpl(esValue[implSymbol]["onload"]);
|
||||
}
|
||||
|
||||
set onload(V) {
|
||||
const esValue = this !== null && this !== undefined ? this : globalObject;
|
||||
|
||||
if (!exports.is(esValue)) {
|
||||
throw new TypeError("Illegal invocation");
|
||||
}
|
||||
|
||||
V = utils.tryImplForWrapper(V);
|
||||
|
||||
esValue[implSymbol]["onload"] = V;
|
||||
}
|
||||
|
||||
get onabort() {
|
||||
const esValue = this !== null && this !== undefined ? this : globalObject;
|
||||
|
||||
if (!exports.is(esValue)) {
|
||||
throw new TypeError("Illegal invocation");
|
||||
}
|
||||
|
||||
return utils.tryWrapperForImpl(esValue[implSymbol]["onabort"]);
|
||||
}
|
||||
|
||||
set onabort(V) {
|
||||
const esValue = this !== null && this !== undefined ? this : globalObject;
|
||||
|
||||
if (!exports.is(esValue)) {
|
||||
throw new TypeError("Illegal invocation");
|
||||
}
|
||||
|
||||
V = utils.tryImplForWrapper(V);
|
||||
|
||||
esValue[implSymbol]["onabort"] = V;
|
||||
}
|
||||
|
||||
get onerror() {
|
||||
const esValue = this !== null && this !== undefined ? this : globalObject;
|
||||
|
||||
if (!exports.is(esValue)) {
|
||||
throw new TypeError("Illegal invocation");
|
||||
}
|
||||
|
||||
return utils.tryWrapperForImpl(esValue[implSymbol]["onerror"]);
|
||||
}
|
||||
|
||||
set onerror(V) {
|
||||
const esValue = this !== null && this !== undefined ? this : globalObject;
|
||||
|
||||
if (!exports.is(esValue)) {
|
||||
throw new TypeError("Illegal invocation");
|
||||
}
|
||||
|
||||
V = utils.tryImplForWrapper(V);
|
||||
|
||||
esValue[implSymbol]["onerror"] = V;
|
||||
}
|
||||
|
||||
get onloadend() {
|
||||
const esValue = this !== null && this !== undefined ? this : globalObject;
|
||||
|
||||
if (!exports.is(esValue)) {
|
||||
throw new TypeError("Illegal invocation");
|
||||
}
|
||||
|
||||
return utils.tryWrapperForImpl(esValue[implSymbol]["onloadend"]);
|
||||
}
|
||||
|
||||
set onloadend(V) {
|
||||
const esValue = this !== null && this !== undefined ? this : globalObject;
|
||||
|
||||
if (!exports.is(esValue)) {
|
||||
throw new TypeError("Illegal invocation");
|
||||
}
|
||||
|
||||
V = utils.tryImplForWrapper(V);
|
||||
|
||||
esValue[implSymbol]["onloadend"] = V;
|
||||
}
|
||||
throw new TypeError(`${context} is not of type 'FileReader'.`);
|
||||
}
|
||||
}; // module.exports
|
||||
Object.defineProperties(FileReader.prototype, {
|
||||
readAsArrayBuffer: { enumerable: true },
|
||||
readAsBinaryString: { enumerable: true },
|
||||
readAsText: { enumerable: true },
|
||||
readAsDataURL: { enumerable: true },
|
||||
abort: { enumerable: true },
|
||||
readyState: { enumerable: true },
|
||||
result: { enumerable: true },
|
||||
error: { enumerable: true },
|
||||
onloadstart: { enumerable: true },
|
||||
onprogress: { enumerable: true },
|
||||
onload: { enumerable: true },
|
||||
onabort: { enumerable: true },
|
||||
onerror: { enumerable: true },
|
||||
onloadend: { enumerable: true },
|
||||
[Symbol.toStringTag]: { value: "FileReader", configurable: true },
|
||||
EMPTY: { value: 0, enumerable: true },
|
||||
LOADING: { value: 1, enumerable: true },
|
||||
DONE: { value: 2, enumerable: true }
|
||||
});
|
||||
Object.defineProperties(FileReader, {
|
||||
EMPTY: { value: 0, enumerable: true },
|
||||
LOADING: { value: 1, enumerable: true },
|
||||
DONE: { value: 2, enumerable: true }
|
||||
});
|
||||
if (globalObject[ctorRegistrySymbol] === undefined) {
|
||||
globalObject[ctorRegistrySymbol] = Object.create(null);
|
||||
}
|
||||
globalObject[ctorRegistrySymbol][interfaceName] = FileReader;
|
||||
|
||||
Object.defineProperty(globalObject, interfaceName, {
|
||||
configurable: true,
|
||||
writable: true,
|
||||
value: FileReader
|
||||
});
|
||||
};
|
||||
|
||||
const Impl = require("../file-api/FileReader-impl.js");
|
||||
|
||||
247
node_modules/jsdom/lib/jsdom/living/generated/FocusEvent.js
generated
vendored
247
node_modules/jsdom/lib/jsdom/living/generated/FocusEvent.js
generated
vendored
@@ -3,145 +3,140 @@
|
||||
const conversions = require("webidl-conversions");
|
||||
const utils = require("./utils.js");
|
||||
|
||||
const convertFocusEventInit = require("./FocusEventInit.js").convert;
|
||||
const impl = utils.implSymbol;
|
||||
const FocusEventInit = require("./FocusEventInit.js");
|
||||
const implSymbol = utils.implSymbol;
|
||||
const ctorRegistrySymbol = utils.ctorRegistrySymbol;
|
||||
const UIEvent = require("./UIEvent.js");
|
||||
|
||||
function FocusEvent(type) {
|
||||
if (new.target === undefined) {
|
||||
throw new TypeError(
|
||||
"Failed to construct 'FocusEvent'. Please use the 'new' operator; this constructor " +
|
||||
"cannot be called as a function."
|
||||
);
|
||||
const interfaceName = "FocusEvent";
|
||||
|
||||
exports.is = value => {
|
||||
return utils.isObject(value) && utils.hasOwn(value, implSymbol) && value[implSymbol] instanceof Impl.implementation;
|
||||
};
|
||||
exports.isImpl = value => {
|
||||
return utils.isObject(value) && value instanceof Impl.implementation;
|
||||
};
|
||||
exports.convert = (value, { context = "The provided value" } = {}) => {
|
||||
if (exports.is(value)) {
|
||||
return utils.implForWrapper(value);
|
||||
}
|
||||
throw new TypeError(`${context} is not of type 'FocusEvent'.`);
|
||||
};
|
||||
|
||||
function makeWrapper(globalObject) {
|
||||
if (globalObject[ctorRegistrySymbol] === undefined) {
|
||||
throw new Error("Internal error: invalid global object");
|
||||
}
|
||||
|
||||
if (arguments.length < 1) {
|
||||
throw new TypeError(
|
||||
"Failed to construct 'FocusEvent': 1 argument required, but only " + arguments.length + " present."
|
||||
);
|
||||
}
|
||||
const args = [];
|
||||
{
|
||||
let curArg = arguments[0];
|
||||
curArg = conversions["DOMString"](curArg, { context: "Failed to construct 'FocusEvent': parameter 1" });
|
||||
args.push(curArg);
|
||||
}
|
||||
{
|
||||
let curArg = arguments[1];
|
||||
curArg = convertFocusEventInit(curArg, { context: "Failed to construct 'FocusEvent': parameter 2" });
|
||||
args.push(curArg);
|
||||
const ctor = globalObject[ctorRegistrySymbol]["FocusEvent"];
|
||||
if (ctor === undefined) {
|
||||
throw new Error("Internal error: constructor FocusEvent is not installed on the passed global object");
|
||||
}
|
||||
|
||||
iface.setup(this, args);
|
||||
return Object.create(ctor.prototype);
|
||||
}
|
||||
|
||||
Object.setPrototypeOf(FocusEvent.prototype, UIEvent.interface.prototype);
|
||||
Object.setPrototypeOf(FocusEvent, UIEvent.interface);
|
||||
exports.create = (globalObject, constructorArgs, privateData) => {
|
||||
const wrapper = makeWrapper(globalObject);
|
||||
return exports.setup(wrapper, globalObject, constructorArgs, privateData);
|
||||
};
|
||||
|
||||
Object.defineProperty(FocusEvent, "prototype", {
|
||||
value: FocusEvent.prototype,
|
||||
writable: false,
|
||||
enumerable: false,
|
||||
configurable: false
|
||||
});
|
||||
exports.createImpl = (globalObject, constructorArgs, privateData) => {
|
||||
const wrapper = exports.create(globalObject, constructorArgs, privateData);
|
||||
return utils.implForWrapper(wrapper);
|
||||
};
|
||||
|
||||
Object.defineProperty(FocusEvent.prototype, "relatedTarget", {
|
||||
get() {
|
||||
if (!this || !module.exports.is(this)) {
|
||||
throw new TypeError("Illegal invocation");
|
||||
}
|
||||
exports._internalSetup = (wrapper, globalObject) => {
|
||||
UIEvent._internalSetup(wrapper, globalObject);
|
||||
};
|
||||
|
||||
return utils.tryWrapperForImpl(this[impl]["relatedTarget"]);
|
||||
},
|
||||
exports.setup = (wrapper, globalObject, constructorArgs = [], privateData = {}) => {
|
||||
privateData.wrapper = wrapper;
|
||||
|
||||
enumerable: true,
|
||||
configurable: true
|
||||
});
|
||||
exports._internalSetup(wrapper, globalObject);
|
||||
Object.defineProperty(wrapper, implSymbol, {
|
||||
value: new Impl.implementation(globalObject, constructorArgs, privateData),
|
||||
configurable: true
|
||||
});
|
||||
|
||||
Object.defineProperty(FocusEvent.prototype, Symbol.toStringTag, {
|
||||
value: "FocusEvent",
|
||||
writable: false,
|
||||
enumerable: false,
|
||||
configurable: true
|
||||
});
|
||||
|
||||
const iface = {
|
||||
// When an interface-module that implements this interface as a mixin is loaded, it will append its own `.is()`
|
||||
// method into this array. It allows objects that directly implements *those* interfaces to be recognized as
|
||||
// implementing this mixin interface.
|
||||
_mixedIntoPredicates: [],
|
||||
is(obj) {
|
||||
if (obj) {
|
||||
if (utils.hasOwn(obj, impl) && obj[impl] instanceof Impl.implementation) {
|
||||
return true;
|
||||
}
|
||||
for (const isMixedInto of module.exports._mixedIntoPredicates) {
|
||||
if (isMixedInto(obj)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
},
|
||||
isImpl(obj) {
|
||||
if (obj) {
|
||||
if (obj instanceof Impl.implementation) {
|
||||
return true;
|
||||
}
|
||||
|
||||
const wrapper = utils.wrapperForImpl(obj);
|
||||
for (const isMixedInto of module.exports._mixedIntoPredicates) {
|
||||
if (isMixedInto(wrapper)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
},
|
||||
convert(obj, { context = "The provided value" } = {}) {
|
||||
if (module.exports.is(obj)) {
|
||||
return utils.implForWrapper(obj);
|
||||
}
|
||||
throw new TypeError(`${context} is not of type 'FocusEvent'.`);
|
||||
},
|
||||
|
||||
create(constructorArgs, privateData) {
|
||||
let obj = Object.create(FocusEvent.prototype);
|
||||
obj = this.setup(obj, constructorArgs, privateData);
|
||||
return obj;
|
||||
},
|
||||
createImpl(constructorArgs, privateData) {
|
||||
let obj = Object.create(FocusEvent.prototype);
|
||||
obj = this.setup(obj, constructorArgs, privateData);
|
||||
return utils.implForWrapper(obj);
|
||||
},
|
||||
_internalSetup(obj) {
|
||||
UIEvent._internalSetup(obj);
|
||||
},
|
||||
setup(obj, constructorArgs, privateData) {
|
||||
if (!privateData) privateData = {};
|
||||
|
||||
privateData.wrapper = obj;
|
||||
|
||||
this._internalSetup(obj);
|
||||
Object.defineProperty(obj, impl, {
|
||||
value: new Impl.implementation(constructorArgs, privateData),
|
||||
writable: false,
|
||||
enumerable: false,
|
||||
configurable: true
|
||||
});
|
||||
|
||||
obj[impl][utils.wrapperSymbol] = obj;
|
||||
if (Impl.init) {
|
||||
Impl.init(obj[impl], privateData);
|
||||
}
|
||||
return obj;
|
||||
},
|
||||
interface: FocusEvent,
|
||||
expose: {
|
||||
Window: { FocusEvent }
|
||||
wrapper[implSymbol][utils.wrapperSymbol] = wrapper;
|
||||
if (Impl.init) {
|
||||
Impl.init(wrapper[implSymbol]);
|
||||
}
|
||||
}; // iface
|
||||
module.exports = iface;
|
||||
return wrapper;
|
||||
};
|
||||
|
||||
exports.new = globalObject => {
|
||||
const wrapper = makeWrapper(globalObject);
|
||||
|
||||
exports._internalSetup(wrapper, globalObject);
|
||||
Object.defineProperty(wrapper, implSymbol, {
|
||||
value: Object.create(Impl.implementation.prototype),
|
||||
configurable: true
|
||||
});
|
||||
|
||||
wrapper[implSymbol][utils.wrapperSymbol] = wrapper;
|
||||
if (Impl.init) {
|
||||
Impl.init(wrapper[implSymbol]);
|
||||
}
|
||||
return wrapper[implSymbol];
|
||||
};
|
||||
|
||||
const exposed = new Set(["Window"]);
|
||||
|
||||
exports.install = (globalObject, globalNames) => {
|
||||
if (!globalNames.some(globalName => exposed.has(globalName))) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (globalObject.UIEvent === undefined) {
|
||||
throw new Error("Internal error: attempting to evaluate FocusEvent before UIEvent");
|
||||
}
|
||||
class FocusEvent extends globalObject.UIEvent {
|
||||
constructor(type) {
|
||||
if (arguments.length < 1) {
|
||||
throw new TypeError(
|
||||
"Failed to construct 'FocusEvent': 1 argument required, but only " + arguments.length + " present."
|
||||
);
|
||||
}
|
||||
const args = [];
|
||||
{
|
||||
let curArg = arguments[0];
|
||||
curArg = conversions["DOMString"](curArg, { context: "Failed to construct 'FocusEvent': parameter 1" });
|
||||
args.push(curArg);
|
||||
}
|
||||
{
|
||||
let curArg = arguments[1];
|
||||
curArg = FocusEventInit.convert(curArg, { context: "Failed to construct 'FocusEvent': parameter 2" });
|
||||
args.push(curArg);
|
||||
}
|
||||
return exports.setup(Object.create(new.target.prototype), globalObject, args);
|
||||
}
|
||||
|
||||
get relatedTarget() {
|
||||
const esValue = this !== null && this !== undefined ? this : globalObject;
|
||||
|
||||
if (!exports.is(esValue)) {
|
||||
throw new TypeError("Illegal invocation");
|
||||
}
|
||||
|
||||
return utils.tryWrapperForImpl(esValue[implSymbol]["relatedTarget"]);
|
||||
}
|
||||
}
|
||||
Object.defineProperties(FocusEvent.prototype, {
|
||||
relatedTarget: { enumerable: true },
|
||||
[Symbol.toStringTag]: { value: "FocusEvent", configurable: true }
|
||||
});
|
||||
if (globalObject[ctorRegistrySymbol] === undefined) {
|
||||
globalObject[ctorRegistrySymbol] = Object.create(null);
|
||||
}
|
||||
globalObject[ctorRegistrySymbol][interfaceName] = FocusEvent;
|
||||
|
||||
Object.defineProperty(globalObject, interfaceName, {
|
||||
configurable: true,
|
||||
writable: true,
|
||||
value: FocusEvent
|
||||
});
|
||||
};
|
||||
|
||||
const Impl = require("../events/FocusEvent-impl.js");
|
||||
|
||||
48
node_modules/jsdom/lib/jsdom/living/generated/FocusEventInit.js
generated
vendored
48
node_modules/jsdom/lib/jsdom/living/generated/FocusEventInit.js
generated
vendored
@@ -3,36 +3,34 @@
|
||||
const conversions = require("webidl-conversions");
|
||||
const utils = require("./utils.js");
|
||||
|
||||
const convertEventTarget = require("./EventTarget.js").convert;
|
||||
const EventTarget = require("./EventTarget.js");
|
||||
const UIEventInit = require("./UIEventInit.js");
|
||||
|
||||
module.exports = {
|
||||
convertInherit(obj, ret, { context = "The provided value" } = {}) {
|
||||
UIEventInit.convertInherit(obj, ret, { context });
|
||||
exports._convertInherit = (obj, ret, { context = "The provided value" } = {}) => {
|
||||
UIEventInit._convertInherit(obj, ret, { context });
|
||||
|
||||
{
|
||||
const key = "relatedTarget";
|
||||
let value = obj === undefined || obj === null ? undefined : obj[key];
|
||||
if (value !== undefined) {
|
||||
if (value === null || value === undefined) {
|
||||
value = null;
|
||||
} else {
|
||||
value = convertEventTarget(value, { context: context + " has member relatedTarget that" });
|
||||
}
|
||||
ret[key] = value;
|
||||
{
|
||||
const key = "relatedTarget";
|
||||
let value = obj === undefined || obj === null ? undefined : obj[key];
|
||||
if (value !== undefined) {
|
||||
if (value === null || value === undefined) {
|
||||
value = null;
|
||||
} else {
|
||||
ret[key] = null;
|
||||
value = EventTarget.convert(value, { context: context + " has member 'relatedTarget' that" });
|
||||
}
|
||||
ret[key] = value;
|
||||
} else {
|
||||
ret[key] = null;
|
||||
}
|
||||
},
|
||||
|
||||
convert(obj, { context = "The provided value" } = {}) {
|
||||
if (obj !== undefined && typeof obj !== "object" && typeof obj !== "function") {
|
||||
throw new TypeError(`${context} is not an object.`);
|
||||
}
|
||||
|
||||
const ret = Object.create(null);
|
||||
module.exports.convertInherit(obj, ret, { context });
|
||||
return ret;
|
||||
}
|
||||
};
|
||||
|
||||
exports.convert = function convert(obj, { context = "The provided value" } = {}) {
|
||||
if (obj !== undefined && typeof obj !== "object" && typeof obj !== "function") {
|
||||
throw new TypeError(`${context} is not an object.`);
|
||||
}
|
||||
|
||||
const ret = Object.create(null);
|
||||
exports._convertInherit(obj, ret, { context });
|
||||
return ret;
|
||||
};
|
||||
|
||||
685
node_modules/jsdom/lib/jsdom/living/generated/FormData.js
generated
vendored
685
node_modules/jsdom/lib/jsdom/living/generated/FormData.js
generated
vendored
@@ -3,17 +3,19 @@
|
||||
const conversions = require("webidl-conversions");
|
||||
const utils = require("./utils.js");
|
||||
|
||||
const convertHTMLFormElement = require("./HTMLFormElement.js").convert;
|
||||
const isBlob = require("./Blob.js").is;
|
||||
const convertBlob = require("./Blob.js").convert;
|
||||
const impl = utils.implSymbol;
|
||||
const HTMLFormElement = require("./HTMLFormElement.js");
|
||||
const Blob = require("./Blob.js");
|
||||
const implSymbol = utils.implSymbol;
|
||||
const ctorRegistrySymbol = utils.ctorRegistrySymbol;
|
||||
|
||||
const interfaceName = "FormData";
|
||||
|
||||
const IteratorPrototype = Object.create(utils.IteratorPrototype, {
|
||||
next: {
|
||||
value: function next() {
|
||||
const internal = this[utils.iterInternalSymbol];
|
||||
const { target, kind, index } = internal;
|
||||
const values = Array.from(target[impl]);
|
||||
const values = Array.from(target[implSymbol]);
|
||||
const len = values.length;
|
||||
if (index >= len) {
|
||||
return { value: undefined, done: true };
|
||||
@@ -42,378 +44,389 @@ const IteratorPrototype = Object.create(utils.IteratorPrototype, {
|
||||
configurable: true
|
||||
},
|
||||
[Symbol.toStringTag]: {
|
||||
value: "FormDataIterator",
|
||||
writable: false,
|
||||
enumerable: false,
|
||||
value: "FormData Iterator",
|
||||
configurable: true
|
||||
}
|
||||
});
|
||||
|
||||
function FormData() {
|
||||
if (new.target === undefined) {
|
||||
throw new TypeError(
|
||||
"Failed to construct 'FormData'. Please use the 'new' operator; this constructor " +
|
||||
"cannot be called as a function."
|
||||
);
|
||||
exports.is = value => {
|
||||
return utils.isObject(value) && utils.hasOwn(value, implSymbol) && value[implSymbol] instanceof Impl.implementation;
|
||||
};
|
||||
exports.isImpl = value => {
|
||||
return utils.isObject(value) && value instanceof Impl.implementation;
|
||||
};
|
||||
exports.convert = (value, { context = "The provided value" } = {}) => {
|
||||
if (exports.is(value)) {
|
||||
return utils.implForWrapper(value);
|
||||
}
|
||||
const args = [];
|
||||
{
|
||||
let curArg = arguments[0];
|
||||
if (curArg !== undefined) {
|
||||
curArg = convertHTMLFormElement(curArg, { context: "Failed to construct 'FormData': parameter 1" });
|
||||
}
|
||||
args.push(curArg);
|
||||
throw new TypeError(`${context} is not of type 'FormData'.`);
|
||||
};
|
||||
|
||||
exports.createDefaultIterator = (target, kind) => {
|
||||
const iterator = Object.create(IteratorPrototype);
|
||||
Object.defineProperty(iterator, utils.iterInternalSymbol, {
|
||||
value: { target, kind, index: 0 },
|
||||
configurable: true
|
||||
});
|
||||
return iterator;
|
||||
};
|
||||
|
||||
function makeWrapper(globalObject) {
|
||||
if (globalObject[ctorRegistrySymbol] === undefined) {
|
||||
throw new Error("Internal error: invalid global object");
|
||||
}
|
||||
|
||||
iface.setup(this, args);
|
||||
const ctor = globalObject[ctorRegistrySymbol]["FormData"];
|
||||
if (ctor === undefined) {
|
||||
throw new Error("Internal error: constructor FormData is not installed on the passed global object");
|
||||
}
|
||||
|
||||
return Object.create(ctor.prototype);
|
||||
}
|
||||
|
||||
Object.defineProperty(FormData, "prototype", {
|
||||
value: FormData.prototype,
|
||||
writable: false,
|
||||
enumerable: false,
|
||||
configurable: false
|
||||
});
|
||||
|
||||
Object.defineProperty(FormData.prototype, Symbol.iterator, {
|
||||
writable: true,
|
||||
enumerable: false,
|
||||
configurable: true,
|
||||
value: function entries() {
|
||||
if (!this || !module.exports.is(this)) {
|
||||
throw new TypeError("Illegal invocation");
|
||||
}
|
||||
return module.exports.createDefaultIterator(this, "key+value");
|
||||
}
|
||||
});
|
||||
FormData.prototype.forEach = function forEach(callback) {
|
||||
if (!this || !module.exports.is(this)) {
|
||||
throw new TypeError("Illegal invocation");
|
||||
}
|
||||
if (arguments.length < 1) {
|
||||
throw new TypeError("Failed to execute 'forEach' on 'FormData': 1 argument required, " + "but only 0 present.");
|
||||
}
|
||||
if (typeof callback !== "function") {
|
||||
throw new TypeError(
|
||||
"Failed to execute 'forEach' on 'FormData': The callback provided " + "as parameter 1 is not a function."
|
||||
);
|
||||
}
|
||||
const thisArg = arguments[1];
|
||||
let pairs = Array.from(this[impl]);
|
||||
let i = 0;
|
||||
while (i < pairs.length) {
|
||||
const [key, value] = pairs[i].map(utils.tryWrapperForImpl);
|
||||
callback.call(thisArg, value, key, this);
|
||||
pairs = Array.from(this[impl]);
|
||||
i++;
|
||||
}
|
||||
exports.create = (globalObject, constructorArgs, privateData) => {
|
||||
const wrapper = makeWrapper(globalObject);
|
||||
return exports.setup(wrapper, globalObject, constructorArgs, privateData);
|
||||
};
|
||||
FormData.prototype.append = function append(name, value) {
|
||||
if (!this || !module.exports.is(this)) {
|
||||
throw new TypeError("Illegal invocation");
|
||||
}
|
||||
|
||||
if (arguments.length < 2) {
|
||||
throw new TypeError(
|
||||
"Failed to execute 'append' on 'FormData': 2 arguments required, but only " + arguments.length + " present."
|
||||
);
|
||||
exports.createImpl = (globalObject, constructorArgs, privateData) => {
|
||||
const wrapper = exports.create(globalObject, constructorArgs, privateData);
|
||||
return utils.implForWrapper(wrapper);
|
||||
};
|
||||
|
||||
exports._internalSetup = (wrapper, globalObject) => {};
|
||||
|
||||
exports.setup = (wrapper, globalObject, constructorArgs = [], privateData = {}) => {
|
||||
privateData.wrapper = wrapper;
|
||||
|
||||
exports._internalSetup(wrapper, globalObject);
|
||||
Object.defineProperty(wrapper, implSymbol, {
|
||||
value: new Impl.implementation(globalObject, constructorArgs, privateData),
|
||||
configurable: true
|
||||
});
|
||||
|
||||
wrapper[implSymbol][utils.wrapperSymbol] = wrapper;
|
||||
if (Impl.init) {
|
||||
Impl.init(wrapper[implSymbol]);
|
||||
}
|
||||
const args = [];
|
||||
switch (arguments.length) {
|
||||
case 2:
|
||||
return wrapper;
|
||||
};
|
||||
|
||||
exports.new = globalObject => {
|
||||
const wrapper = makeWrapper(globalObject);
|
||||
|
||||
exports._internalSetup(wrapper, globalObject);
|
||||
Object.defineProperty(wrapper, implSymbol, {
|
||||
value: Object.create(Impl.implementation.prototype),
|
||||
configurable: true
|
||||
});
|
||||
|
||||
wrapper[implSymbol][utils.wrapperSymbol] = wrapper;
|
||||
if (Impl.init) {
|
||||
Impl.init(wrapper[implSymbol]);
|
||||
}
|
||||
return wrapper[implSymbol];
|
||||
};
|
||||
|
||||
const exposed = new Set(["Window", "Worker"]);
|
||||
|
||||
exports.install = (globalObject, globalNames) => {
|
||||
if (!globalNames.some(globalName => exposed.has(globalName))) {
|
||||
return;
|
||||
}
|
||||
class FormData {
|
||||
constructor() {
|
||||
const args = [];
|
||||
{
|
||||
let curArg = arguments[0];
|
||||
curArg = conversions["USVString"](curArg, { context: "Failed to execute 'append' on 'FormData': parameter 1" });
|
||||
if (curArg !== undefined) {
|
||||
curArg = HTMLFormElement.convert(curArg, { context: "Failed to construct 'FormData': parameter 1" });
|
||||
}
|
||||
args.push(curArg);
|
||||
}
|
||||
{
|
||||
let curArg = arguments[1];
|
||||
if (isBlob(curArg)) {
|
||||
return exports.setup(Object.create(new.target.prototype), globalObject, args);
|
||||
}
|
||||
|
||||
append(name, value) {
|
||||
const esValue = this !== null && this !== undefined ? this : globalObject;
|
||||
if (!exports.is(esValue)) {
|
||||
throw new TypeError("Illegal invocation");
|
||||
}
|
||||
|
||||
if (arguments.length < 2) {
|
||||
throw new TypeError(
|
||||
"Failed to execute 'append' on 'FormData': 2 arguments required, but only " + arguments.length + " present."
|
||||
);
|
||||
}
|
||||
const args = [];
|
||||
switch (arguments.length) {
|
||||
case 2:
|
||||
{
|
||||
let curArg = arguments[1];
|
||||
curArg = convertBlob(curArg, { context: "Failed to execute 'append' on 'FormData': parameter 2" });
|
||||
args.push(curArg);
|
||||
}
|
||||
} else {
|
||||
{
|
||||
let curArg = arguments[1];
|
||||
let curArg = arguments[0];
|
||||
curArg = conversions["USVString"](curArg, {
|
||||
context: "Failed to execute 'append' on 'FormData': parameter 2"
|
||||
context: "Failed to execute 'append' on 'FormData': parameter 1"
|
||||
});
|
||||
args.push(curArg);
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
default:
|
||||
{
|
||||
let curArg = arguments[0];
|
||||
curArg = conversions["USVString"](curArg, { context: "Failed to execute 'append' on 'FormData': parameter 1" });
|
||||
args.push(curArg);
|
||||
}
|
||||
{
|
||||
let curArg = arguments[1];
|
||||
curArg = convertBlob(curArg, { context: "Failed to execute 'append' on 'FormData': parameter 2" });
|
||||
args.push(curArg);
|
||||
}
|
||||
{
|
||||
let curArg = arguments[2];
|
||||
if (curArg !== undefined) {
|
||||
curArg = conversions["USVString"](curArg, {
|
||||
context: "Failed to execute 'append' on 'FormData': parameter 3"
|
||||
});
|
||||
}
|
||||
args.push(curArg);
|
||||
}
|
||||
}
|
||||
return this[impl].append(...args);
|
||||
};
|
||||
|
||||
FormData.prototype.delete = function _delete(name) {
|
||||
if (!this || !module.exports.is(this)) {
|
||||
throw new TypeError("Illegal invocation");
|
||||
}
|
||||
|
||||
if (arguments.length < 1) {
|
||||
throw new TypeError(
|
||||
"Failed to execute 'delete' on 'FormData': 1 argument required, but only " + arguments.length + " present."
|
||||
);
|
||||
}
|
||||
const args = [];
|
||||
{
|
||||
let curArg = arguments[0];
|
||||
curArg = conversions["USVString"](curArg, { context: "Failed to execute 'delete' on 'FormData': parameter 1" });
|
||||
args.push(curArg);
|
||||
}
|
||||
return this[impl].delete(...args);
|
||||
};
|
||||
|
||||
FormData.prototype.get = function get(name) {
|
||||
if (!this || !module.exports.is(this)) {
|
||||
throw new TypeError("Illegal invocation");
|
||||
}
|
||||
|
||||
if (arguments.length < 1) {
|
||||
throw new TypeError(
|
||||
"Failed to execute 'get' on 'FormData': 1 argument required, but only " + arguments.length + " present."
|
||||
);
|
||||
}
|
||||
const args = [];
|
||||
{
|
||||
let curArg = arguments[0];
|
||||
curArg = conversions["USVString"](curArg, { context: "Failed to execute 'get' on 'FormData': parameter 1" });
|
||||
args.push(curArg);
|
||||
}
|
||||
return utils.tryWrapperForImpl(this[impl].get(...args));
|
||||
};
|
||||
|
||||
FormData.prototype.getAll = function getAll(name) {
|
||||
if (!this || !module.exports.is(this)) {
|
||||
throw new TypeError("Illegal invocation");
|
||||
}
|
||||
|
||||
if (arguments.length < 1) {
|
||||
throw new TypeError(
|
||||
"Failed to execute 'getAll' on 'FormData': 1 argument required, but only " + arguments.length + " present."
|
||||
);
|
||||
}
|
||||
const args = [];
|
||||
{
|
||||
let curArg = arguments[0];
|
||||
curArg = conversions["USVString"](curArg, { context: "Failed to execute 'getAll' on 'FormData': parameter 1" });
|
||||
args.push(curArg);
|
||||
}
|
||||
return utils.tryWrapperForImpl(this[impl].getAll(...args));
|
||||
};
|
||||
|
||||
FormData.prototype.has = function has(name) {
|
||||
if (!this || !module.exports.is(this)) {
|
||||
throw new TypeError("Illegal invocation");
|
||||
}
|
||||
|
||||
if (arguments.length < 1) {
|
||||
throw new TypeError(
|
||||
"Failed to execute 'has' on 'FormData': 1 argument required, but only " + arguments.length + " present."
|
||||
);
|
||||
}
|
||||
const args = [];
|
||||
{
|
||||
let curArg = arguments[0];
|
||||
curArg = conversions["USVString"](curArg, { context: "Failed to execute 'has' on 'FormData': parameter 1" });
|
||||
args.push(curArg);
|
||||
}
|
||||
return this[impl].has(...args);
|
||||
};
|
||||
|
||||
FormData.prototype.set = function set(name, value) {
|
||||
if (!this || !module.exports.is(this)) {
|
||||
throw new TypeError("Illegal invocation");
|
||||
}
|
||||
|
||||
if (arguments.length < 2) {
|
||||
throw new TypeError(
|
||||
"Failed to execute 'set' on 'FormData': 2 arguments required, but only " + arguments.length + " present."
|
||||
);
|
||||
}
|
||||
const args = [];
|
||||
switch (arguments.length) {
|
||||
case 2:
|
||||
{
|
||||
let curArg = arguments[0];
|
||||
curArg = conversions["USVString"](curArg, { context: "Failed to execute 'set' on 'FormData': parameter 1" });
|
||||
args.push(curArg);
|
||||
}
|
||||
{
|
||||
let curArg = arguments[1];
|
||||
if (isBlob(curArg)) {
|
||||
{
|
||||
let curArg = arguments[1];
|
||||
curArg = convertBlob(curArg, { context: "Failed to execute 'set' on 'FormData': parameter 2" });
|
||||
args.push(curArg);
|
||||
if (Blob.is(curArg)) {
|
||||
{
|
||||
let curArg = arguments[1];
|
||||
curArg = Blob.convert(curArg, { context: "Failed to execute 'append' on 'FormData': parameter 2" });
|
||||
args.push(curArg);
|
||||
}
|
||||
} else {
|
||||
{
|
||||
let curArg = arguments[1];
|
||||
curArg = conversions["USVString"](curArg, {
|
||||
context: "Failed to execute 'append' on 'FormData': parameter 2"
|
||||
});
|
||||
args.push(curArg);
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
break;
|
||||
default:
|
||||
{
|
||||
let curArg = arguments[1];
|
||||
let curArg = arguments[0];
|
||||
curArg = conversions["USVString"](curArg, {
|
||||
context: "Failed to execute 'set' on 'FormData': parameter 2"
|
||||
context: "Failed to execute 'append' on 'FormData': parameter 1"
|
||||
});
|
||||
args.push(curArg);
|
||||
}
|
||||
}
|
||||
{
|
||||
let curArg = arguments[1];
|
||||
curArg = Blob.convert(curArg, { context: "Failed to execute 'append' on 'FormData': parameter 2" });
|
||||
args.push(curArg);
|
||||
}
|
||||
{
|
||||
let curArg = arguments[2];
|
||||
if (curArg !== undefined) {
|
||||
curArg = conversions["USVString"](curArg, {
|
||||
context: "Failed to execute 'append' on 'FormData': parameter 3"
|
||||
});
|
||||
}
|
||||
args.push(curArg);
|
||||
}
|
||||
}
|
||||
break;
|
||||
default:
|
||||
return esValue[implSymbol].append(...args);
|
||||
}
|
||||
|
||||
delete(name) {
|
||||
const esValue = this !== null && this !== undefined ? this : globalObject;
|
||||
if (!exports.is(esValue)) {
|
||||
throw new TypeError("Illegal invocation");
|
||||
}
|
||||
|
||||
if (arguments.length < 1) {
|
||||
throw new TypeError(
|
||||
"Failed to execute 'delete' on 'FormData': 1 argument required, but only " + arguments.length + " present."
|
||||
);
|
||||
}
|
||||
const args = [];
|
||||
{
|
||||
let curArg = arguments[0];
|
||||
curArg = conversions["USVString"](curArg, { context: "Failed to execute 'set' on 'FormData': parameter 1" });
|
||||
curArg = conversions["USVString"](curArg, { context: "Failed to execute 'delete' on 'FormData': parameter 1" });
|
||||
args.push(curArg);
|
||||
}
|
||||
return esValue[implSymbol].delete(...args);
|
||||
}
|
||||
|
||||
get(name) {
|
||||
const esValue = this !== null && this !== undefined ? this : globalObject;
|
||||
if (!exports.is(esValue)) {
|
||||
throw new TypeError("Illegal invocation");
|
||||
}
|
||||
|
||||
if (arguments.length < 1) {
|
||||
throw new TypeError(
|
||||
"Failed to execute 'get' on 'FormData': 1 argument required, but only " + arguments.length + " present."
|
||||
);
|
||||
}
|
||||
const args = [];
|
||||
{
|
||||
let curArg = arguments[1];
|
||||
curArg = convertBlob(curArg, { context: "Failed to execute 'set' on 'FormData': parameter 2" });
|
||||
let curArg = arguments[0];
|
||||
curArg = conversions["USVString"](curArg, { context: "Failed to execute 'get' on 'FormData': parameter 1" });
|
||||
args.push(curArg);
|
||||
}
|
||||
return utils.tryWrapperForImpl(esValue[implSymbol].get(...args));
|
||||
}
|
||||
|
||||
getAll(name) {
|
||||
const esValue = this !== null && this !== undefined ? this : globalObject;
|
||||
if (!exports.is(esValue)) {
|
||||
throw new TypeError("Illegal invocation");
|
||||
}
|
||||
|
||||
if (arguments.length < 1) {
|
||||
throw new TypeError(
|
||||
"Failed to execute 'getAll' on 'FormData': 1 argument required, but only " + arguments.length + " present."
|
||||
);
|
||||
}
|
||||
const args = [];
|
||||
{
|
||||
let curArg = arguments[2];
|
||||
if (curArg !== undefined) {
|
||||
curArg = conversions["USVString"](curArg, { context: "Failed to execute 'set' on 'FormData': parameter 3" });
|
||||
}
|
||||
let curArg = arguments[0];
|
||||
curArg = conversions["USVString"](curArg, { context: "Failed to execute 'getAll' on 'FormData': parameter 1" });
|
||||
args.push(curArg);
|
||||
}
|
||||
return utils.tryWrapperForImpl(esValue[implSymbol].getAll(...args));
|
||||
}
|
||||
|
||||
has(name) {
|
||||
const esValue = this !== null && this !== undefined ? this : globalObject;
|
||||
if (!exports.is(esValue)) {
|
||||
throw new TypeError("Illegal invocation");
|
||||
}
|
||||
|
||||
if (arguments.length < 1) {
|
||||
throw new TypeError(
|
||||
"Failed to execute 'has' on 'FormData': 1 argument required, but only " + arguments.length + " present."
|
||||
);
|
||||
}
|
||||
const args = [];
|
||||
{
|
||||
let curArg = arguments[0];
|
||||
curArg = conversions["USVString"](curArg, { context: "Failed to execute 'has' on 'FormData': parameter 1" });
|
||||
args.push(curArg);
|
||||
}
|
||||
return esValue[implSymbol].has(...args);
|
||||
}
|
||||
|
||||
set(name, value) {
|
||||
const esValue = this !== null && this !== undefined ? this : globalObject;
|
||||
if (!exports.is(esValue)) {
|
||||
throw new TypeError("Illegal invocation");
|
||||
}
|
||||
|
||||
if (arguments.length < 2) {
|
||||
throw new TypeError(
|
||||
"Failed to execute 'set' on 'FormData': 2 arguments required, but only " + arguments.length + " present."
|
||||
);
|
||||
}
|
||||
const args = [];
|
||||
switch (arguments.length) {
|
||||
case 2:
|
||||
{
|
||||
let curArg = arguments[0];
|
||||
curArg = conversions["USVString"](curArg, {
|
||||
context: "Failed to execute 'set' on 'FormData': parameter 1"
|
||||
});
|
||||
args.push(curArg);
|
||||
}
|
||||
{
|
||||
let curArg = arguments[1];
|
||||
if (Blob.is(curArg)) {
|
||||
{
|
||||
let curArg = arguments[1];
|
||||
curArg = Blob.convert(curArg, { context: "Failed to execute 'set' on 'FormData': parameter 2" });
|
||||
args.push(curArg);
|
||||
}
|
||||
} else {
|
||||
{
|
||||
let curArg = arguments[1];
|
||||
curArg = conversions["USVString"](curArg, {
|
||||
context: "Failed to execute 'set' on 'FormData': parameter 2"
|
||||
});
|
||||
args.push(curArg);
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
default:
|
||||
{
|
||||
let curArg = arguments[0];
|
||||
curArg = conversions["USVString"](curArg, {
|
||||
context: "Failed to execute 'set' on 'FormData': parameter 1"
|
||||
});
|
||||
args.push(curArg);
|
||||
}
|
||||
{
|
||||
let curArg = arguments[1];
|
||||
curArg = Blob.convert(curArg, { context: "Failed to execute 'set' on 'FormData': parameter 2" });
|
||||
args.push(curArg);
|
||||
}
|
||||
{
|
||||
let curArg = arguments[2];
|
||||
if (curArg !== undefined) {
|
||||
curArg = conversions["USVString"](curArg, {
|
||||
context: "Failed to execute 'set' on 'FormData': parameter 3"
|
||||
});
|
||||
}
|
||||
args.push(curArg);
|
||||
}
|
||||
}
|
||||
return esValue[implSymbol].set(...args);
|
||||
}
|
||||
|
||||
keys() {
|
||||
if (!this || !exports.is(this)) {
|
||||
throw new TypeError("Illegal invocation");
|
||||
}
|
||||
return exports.createDefaultIterator(this, "key");
|
||||
}
|
||||
|
||||
values() {
|
||||
if (!this || !exports.is(this)) {
|
||||
throw new TypeError("Illegal invocation");
|
||||
}
|
||||
return exports.createDefaultIterator(this, "value");
|
||||
}
|
||||
|
||||
entries() {
|
||||
if (!this || !exports.is(this)) {
|
||||
throw new TypeError("Illegal invocation");
|
||||
}
|
||||
return exports.createDefaultIterator(this, "key+value");
|
||||
}
|
||||
|
||||
forEach(callback) {
|
||||
if (!this || !exports.is(this)) {
|
||||
throw new TypeError("Illegal invocation");
|
||||
}
|
||||
if (arguments.length < 1) {
|
||||
throw new TypeError("Failed to execute 'forEach' on 'iterable': 1 argument required, " + "but only 0 present.");
|
||||
}
|
||||
if (typeof callback !== "function") {
|
||||
throw new TypeError(
|
||||
"Failed to execute 'forEach' on 'iterable': The callback provided " + "as parameter 1 is not a function."
|
||||
);
|
||||
}
|
||||
const thisArg = arguments[1];
|
||||
let pairs = Array.from(this[implSymbol]);
|
||||
let i = 0;
|
||||
while (i < pairs.length) {
|
||||
const [key, value] = pairs[i].map(utils.tryWrapperForImpl);
|
||||
callback.call(thisArg, value, key, this);
|
||||
pairs = Array.from(this[implSymbol]);
|
||||
i++;
|
||||
}
|
||||
}
|
||||
}
|
||||
return this[impl].set(...args);
|
||||
Object.defineProperties(FormData.prototype, {
|
||||
append: { enumerable: true },
|
||||
delete: { enumerable: true },
|
||||
get: { enumerable: true },
|
||||
getAll: { enumerable: true },
|
||||
has: { enumerable: true },
|
||||
set: { enumerable: true },
|
||||
keys: { enumerable: true },
|
||||
values: { enumerable: true },
|
||||
entries: { enumerable: true },
|
||||
forEach: { enumerable: true },
|
||||
[Symbol.toStringTag]: { value: "FormData", configurable: true },
|
||||
[Symbol.iterator]: { value: FormData.prototype.entries, configurable: true, writable: true }
|
||||
});
|
||||
if (globalObject[ctorRegistrySymbol] === undefined) {
|
||||
globalObject[ctorRegistrySymbol] = Object.create(null);
|
||||
}
|
||||
globalObject[ctorRegistrySymbol][interfaceName] = FormData;
|
||||
|
||||
Object.defineProperty(globalObject, interfaceName, {
|
||||
configurable: true,
|
||||
writable: true,
|
||||
value: FormData
|
||||
});
|
||||
};
|
||||
|
||||
FormData.prototype.entries = FormData.prototype[Symbol.iterator];
|
||||
|
||||
FormData.prototype.keys = function keys() {
|
||||
if (!this || !module.exports.is(this)) {
|
||||
throw new TypeError("Illegal invocation");
|
||||
}
|
||||
return module.exports.createDefaultIterator(this, "key");
|
||||
};
|
||||
|
||||
FormData.prototype.values = function values() {
|
||||
if (!this || !module.exports.is(this)) {
|
||||
throw new TypeError("Illegal invocation");
|
||||
}
|
||||
return module.exports.createDefaultIterator(this, "value");
|
||||
};
|
||||
|
||||
Object.defineProperty(FormData.prototype, Symbol.toStringTag, {
|
||||
value: "FormData",
|
||||
writable: false,
|
||||
enumerable: false,
|
||||
configurable: true
|
||||
});
|
||||
|
||||
const iface = {
|
||||
// When an interface-module that implements this interface as a mixin is loaded, it will append its own `.is()`
|
||||
// method into this array. It allows objects that directly implements *those* interfaces to be recognized as
|
||||
// implementing this mixin interface.
|
||||
_mixedIntoPredicates: [],
|
||||
is(obj) {
|
||||
if (obj) {
|
||||
if (utils.hasOwn(obj, impl) && obj[impl] instanceof Impl.implementation) {
|
||||
return true;
|
||||
}
|
||||
for (const isMixedInto of module.exports._mixedIntoPredicates) {
|
||||
if (isMixedInto(obj)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
},
|
||||
isImpl(obj) {
|
||||
if (obj) {
|
||||
if (obj instanceof Impl.implementation) {
|
||||
return true;
|
||||
}
|
||||
|
||||
const wrapper = utils.wrapperForImpl(obj);
|
||||
for (const isMixedInto of module.exports._mixedIntoPredicates) {
|
||||
if (isMixedInto(wrapper)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
},
|
||||
convert(obj, { context = "The provided value" } = {}) {
|
||||
if (module.exports.is(obj)) {
|
||||
return utils.implForWrapper(obj);
|
||||
}
|
||||
throw new TypeError(`${context} is not of type 'FormData'.`);
|
||||
},
|
||||
|
||||
createDefaultIterator(target, kind) {
|
||||
const iterator = Object.create(IteratorPrototype);
|
||||
Object.defineProperty(iterator, utils.iterInternalSymbol, {
|
||||
value: { target, kind, index: 0 },
|
||||
writable: false,
|
||||
enumerable: false,
|
||||
configurable: true
|
||||
});
|
||||
return iterator;
|
||||
},
|
||||
|
||||
create(constructorArgs, privateData) {
|
||||
let obj = Object.create(FormData.prototype);
|
||||
obj = this.setup(obj, constructorArgs, privateData);
|
||||
return obj;
|
||||
},
|
||||
createImpl(constructorArgs, privateData) {
|
||||
let obj = Object.create(FormData.prototype);
|
||||
obj = this.setup(obj, constructorArgs, privateData);
|
||||
return utils.implForWrapper(obj);
|
||||
},
|
||||
_internalSetup(obj) {},
|
||||
setup(obj, constructorArgs, privateData) {
|
||||
if (!privateData) privateData = {};
|
||||
|
||||
privateData.wrapper = obj;
|
||||
|
||||
this._internalSetup(obj);
|
||||
Object.defineProperty(obj, impl, {
|
||||
value: new Impl.implementation(constructorArgs, privateData),
|
||||
writable: false,
|
||||
enumerable: false,
|
||||
configurable: true
|
||||
});
|
||||
|
||||
obj[impl][utils.wrapperSymbol] = obj;
|
||||
if (Impl.init) {
|
||||
Impl.init(obj[impl], privateData);
|
||||
}
|
||||
return obj;
|
||||
},
|
||||
interface: FormData,
|
||||
expose: {
|
||||
Window: { FormData },
|
||||
Worker: { FormData }
|
||||
}
|
||||
}; // iface
|
||||
module.exports = iface;
|
||||
|
||||
const Impl = require("../xhr/FormData-impl.js");
|
||||
|
||||
40
node_modules/jsdom/lib/jsdom/living/generated/GetRootNodeOptions.js
generated
vendored
40
node_modules/jsdom/lib/jsdom/living/generated/GetRootNodeOptions.js
generated
vendored
@@ -3,28 +3,26 @@
|
||||
const conversions = require("webidl-conversions");
|
||||
const utils = require("./utils.js");
|
||||
|
||||
module.exports = {
|
||||
convertInherit(obj, ret, { context = "The provided value" } = {}) {
|
||||
{
|
||||
const key = "composed";
|
||||
let value = obj === undefined || obj === null ? undefined : obj[key];
|
||||
if (value !== undefined) {
|
||||
value = conversions["boolean"](value, { context: context + " has member composed that" });
|
||||
exports._convertInherit = (obj, ret, { context = "The provided value" } = {}) => {
|
||||
{
|
||||
const key = "composed";
|
||||
let value = obj === undefined || obj === null ? undefined : obj[key];
|
||||
if (value !== undefined) {
|
||||
value = conversions["boolean"](value, { context: context + " has member 'composed' that" });
|
||||
|
||||
ret[key] = value;
|
||||
} else {
|
||||
ret[key] = false;
|
||||
}
|
||||
ret[key] = value;
|
||||
} else {
|
||||
ret[key] = false;
|
||||
}
|
||||
},
|
||||
|
||||
convert(obj, { context = "The provided value" } = {}) {
|
||||
if (obj !== undefined && typeof obj !== "object" && typeof obj !== "function") {
|
||||
throw new TypeError(`${context} is not an object.`);
|
||||
}
|
||||
|
||||
const ret = Object.create(null);
|
||||
module.exports.convertInherit(obj, ret, { context });
|
||||
return ret;
|
||||
}
|
||||
};
|
||||
|
||||
exports.convert = function convert(obj, { context = "The provided value" } = {}) {
|
||||
if (obj !== undefined && typeof obj !== "object" && typeof obj !== "function") {
|
||||
throw new TypeError(`${context} is not an object.`);
|
||||
}
|
||||
|
||||
const ret = Object.create(null);
|
||||
exports._convertInherit(obj, ret, { context });
|
||||
return ret;
|
||||
};
|
||||
|
||||
1511
node_modules/jsdom/lib/jsdom/living/generated/GlobalEventHandlers.js
generated
vendored
1511
node_modules/jsdom/lib/jsdom/living/generated/GlobalEventHandlers.js
generated
vendored
File diff suppressed because it is too large
Load Diff
1554
node_modules/jsdom/lib/jsdom/living/generated/HTMLAnchorElement.js
generated
vendored
1554
node_modules/jsdom/lib/jsdom/living/generated/HTMLAnchorElement.js
generated
vendored
File diff suppressed because it is too large
Load Diff
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user