Comparing version 20.0.3 to 21.0.0
@@ -139,3 +139,3 @@ "use strict"; | ||
contentType: res.headers["content-type"], | ||
referrer: req.getHeader("referer") | ||
referrer: req.getHeader("referer") ?? undefined | ||
}); | ||
@@ -142,0 +142,0 @@ |
@@ -71,3 +71,6 @@ "use strict"; | ||
this._asyncQueue.push(request, onLoadWrapped, onErrorWrapped, this._queue.getLastScript()); | ||
} else if (element.localName === "script" && element.hasAttributeNS(null, "defer")) { | ||
} else if ( | ||
element.localName === "script" && | ||
element.hasAttributeNS(null, "defer") && | ||
this._document.readyState !== "interactive") { | ||
this._deferQueue.push(request, onLoadWrapped, onErrorWrapped, false, element); | ||
@@ -74,0 +77,0 @@ } else { |
@@ -217,2 +217,18 @@ "use strict"; | ||
function makeReplaceablePropertyDescriptor(property, window) { | ||
const desc = { | ||
set(value) { | ||
Object.defineProperty(window, property, { | ||
configurable: true, | ||
enumerable: true, | ||
writable: true, | ||
value | ||
}); | ||
} | ||
}; | ||
Object.defineProperty(desc.set, "name", { value: `set ${property}` }); | ||
return desc; | ||
} | ||
// NOTE: per https://heycam.github.io/webidl/#Global, all properties on the Window object must be own-properties. | ||
@@ -379,2 +395,6 @@ // That is why we assign everything inside of the constructor, instead of using a shared prototype. | ||
}, | ||
// [PutForwards=href]: | ||
set location(value) { | ||
Reflect.set(window.location, "href", value); | ||
}, | ||
get history() { | ||
@@ -416,11 +436,2 @@ return idlUtils.wrapperForImpl(idlUtils.implForWrapper(window._document)._history); | ||
}, | ||
// The origin IDL attribute is defined with [Replaceable]. | ||
set origin(value) { | ||
Object.defineProperty(this, "origin", { | ||
value, | ||
writable: true, | ||
enumerable: true, | ||
configurable: true | ||
}); | ||
}, | ||
get localStorage() { | ||
@@ -451,8 +462,30 @@ if (idlUtils.implForWrapper(this._document)._origin === "null") { | ||
return window._currentEvent ? idlUtils.wrapperForImpl(window._currentEvent) : undefined; | ||
}, | ||
set event(value) { | ||
Object.defineProperty(window, "event", { configurable: true, enumerable: true, writable: true, value }); | ||
} | ||
}); | ||
Object.defineProperties(this, { | ||
// [Replaceable]: | ||
self: makeReplaceablePropertyDescriptor("self", window), | ||
locationbar: makeReplaceablePropertyDescriptor("locationbar", window), | ||
menubar: makeReplaceablePropertyDescriptor("menubar", window), | ||
personalbar: makeReplaceablePropertyDescriptor("personalbar", window), | ||
scrollbars: makeReplaceablePropertyDescriptor("scrollbars", window), | ||
statusbar: makeReplaceablePropertyDescriptor("statusbar", window), | ||
toolbar: makeReplaceablePropertyDescriptor("toolbar", window), | ||
frames: makeReplaceablePropertyDescriptor("frames", window), | ||
parent: makeReplaceablePropertyDescriptor("parent", window), | ||
external: makeReplaceablePropertyDescriptor("external", window), | ||
length: makeReplaceablePropertyDescriptor("length", window), | ||
screen: makeReplaceablePropertyDescriptor("screen", window), | ||
origin: makeReplaceablePropertyDescriptor("origin", window), | ||
event: makeReplaceablePropertyDescriptor("event", window), | ||
// [LegacyUnforgeable]: | ||
window: { configurable: false }, | ||
document: { configurable: false }, | ||
location: { configurable: false }, | ||
top: { configurable: false } | ||
}); | ||
namedPropertiesWindow.initializeWindow(this, this._globalProxy); | ||
@@ -459,0 +492,0 @@ |
@@ -11,9 +11,3 @@ "use strict"; | ||
function abortRequest(clientRequest) { | ||
// clientRequest.destroy breaks the test suite for versions 10 and 12, | ||
// hence the version check | ||
if (majorNodeVersion > 13) { | ||
clientRequest.destroy(); | ||
} else { | ||
clientRequest.abort(); | ||
} | ||
clientRequest.destroy(); | ||
clientRequest.removeAllListeners(); | ||
@@ -99,5 +93,17 @@ clientRequest.on("error", () => {}); | ||
const scheme = urlOptions.protocol; | ||
this._requestOptions.agent = this.agents[scheme.substring(0, scheme.length - 1)]; | ||
// browserify's (http|https).request() does not work correctly with the (url, options, callback) signature. Instead | ||
// we need to have options for each of the URL components. Note that we can't use the spread operator because URL | ||
// instances don't have own properties for the URL components. | ||
const requestOptions = { | ||
...this._requestOptions, | ||
agent: this.agents[scheme.substring(0, scheme.length - 1)], | ||
protocol: urlOptions.protocol, | ||
hostname: urlOptions.hostname, | ||
port: urlOptions.port, | ||
path: urlOptions.pathname + urlOptions.search | ||
}; | ||
const { request } = scheme === "https:" ? https : http; | ||
this._currentRequest = request(this.currentURL, this._requestOptions, response => { | ||
this._currentRequest = request(requestOptions, response => { | ||
this._processResponse(response); | ||
@@ -216,5 +222,6 @@ }); | ||
) { | ||
// Browserify's zlib does not support zlib.constants. | ||
const zlibOptions = { | ||
flush: zlib.constants.Z_SYNC_FLUSH, | ||
finishFlush: zlib.constants.Z_SYNC_FLUSH | ||
flush: (zlib.constants ?? zlib).Z_SYNC_FLUSH, | ||
finishFlush: (zlib.constants ?? zlib).Z_SYNC_FLUSH | ||
}; | ||
@@ -221,0 +228,0 @@ const contentEncoding = (response.headers["content-encoding"] || "identity").trim().toLowerCase(); |
@@ -18,5 +18,2 @@ "use strict"; | ||
} | ||
set style(value) { | ||
this._style.cssText = value; | ||
} | ||
} | ||
@@ -23,0 +20,0 @@ |
@@ -203,3 +203,3 @@ "use strict"; | ||
} | ||
} else if (form && this.type === "submit") { | ||
} else if (form && (this.type === "submit" || this.type === "image")) { | ||
form._doRequestSubmit(this); | ||
@@ -206,0 +206,0 @@ } else if (form && this.type === "reset") { |
@@ -45,6 +45,2 @@ "use strict"; | ||
this._labels = null; | ||
// Essentially a cache for the current selected element for use while building a select by appending options. | ||
// See _selectednessSettingAlgorithmWithKnownNewAddition(). | ||
this._lastSelectedOptionForFastPath = null; | ||
} | ||
@@ -61,6 +57,2 @@ | ||
_askedForAReset() { | ||
this._selectednessSettingAlgorithm(); | ||
} | ||
_selectednessSettingAlgorithm() { | ||
if (this.hasAttributeNS(null, "multiple")) { | ||
@@ -87,3 +79,2 @@ return; | ||
option._selectedness = true; | ||
this._lastSelectedOptionForFastPath = option; | ||
break; | ||
@@ -97,42 +88,8 @@ } | ||
}); | ||
this._lastSelectedOptionForFastPath = selected[selected.length - 1]; | ||
} | ||
} | ||
_selectednessSettingAlgorithmWithKnownNewAddition(child) { | ||
if (this.hasAttributeNS(null, "multiple")) { | ||
return; | ||
} | ||
if (child.hasAttributeNS(null, "disabled")) { | ||
return; | ||
} | ||
const optArr = toOptionArray(child); | ||
if (optArr.length === 0) { | ||
return; | ||
} | ||
const selectedOptions = optArr.filter(opt => opt._selectedness); | ||
// If any selected is last selected | ||
if (selectedOptions.length > 0) { | ||
// pushed at least one element with selected=true, reset | ||
this._askedForAReset(); | ||
return; | ||
} | ||
// No selection so first option is selected | ||
if ((!this._lastSelectedOptionForFastPath || !this._lastSelectedOptionForFastPath._selectedness) && | ||
this._displaySize === 1) { | ||
this._lastSelectedOptionForFastPath = optArr[0]; | ||
this._lastSelectedOptionForFastPath._selectedness = true; | ||
} | ||
} | ||
_descendantAdded(parent, child) { | ||
if (child.nodeType === NODE_TYPE.ELEMENT_NODE) { | ||
if (parent === this) { | ||
this._selectednessSettingAlgorithmWithKnownNewAddition(child); | ||
} else if (parent._localName === "optgroup") { | ||
this._selectednessSettingAlgorithmWithKnownNewAddition(parent); | ||
} else { | ||
this._askedForAReset(); | ||
} | ||
this._askedForAReset(); | ||
} | ||
@@ -145,5 +102,2 @@ | ||
if (child.nodeType === NODE_TYPE.ELEMENT_NODE) { | ||
if (this._lastSelectedOptionForFastPath === child) { | ||
this._lastSelectedOptionForFastPath = null; | ||
} | ||
this._askedForAReset(); | ||
@@ -332,18 +286,4 @@ } | ||
function toOptionArray(child) { | ||
const array = []; | ||
if (child._localName === "option" && !child.hasAttributeNS(null, "disabled")) { | ||
array.push(child); | ||
} else if (child._localName === "optgroup") { | ||
for (const childOfGroup of domSymbolTree.childrenIterator(child)) { | ||
if (childOfGroup._localName === "option" && !childOfGroup.hasAttributeNS(null, "disabled")) { | ||
array.push(childOfGroup); | ||
} | ||
} | ||
} | ||
return array; | ||
} | ||
module.exports = { | ||
implementation: HTMLSelectElementImpl | ||
}; |
{ | ||
"name": "jsdom", | ||
"version": "20.0.3", | ||
"version": "21.0.0", | ||
"description": "A JavaScript implementation of many web standards", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
@@ -54,3 +54,3 @@ <h1 align="center"> | ||
- `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`, 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). | ||
- `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. | ||
@@ -145,4 +145,2 @@ - `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. | ||
_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: | ||
@@ -165,3 +163,3 @@ | ||
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: | ||
You can further customize resource fetching by subclassing `ResourceLoader` and overriding the `fetch()` method. For example, here is a version that overrides the response provided for a specific URL: | ||
@@ -468,3 +466,3 @@ ```js | ||
By default jsdom elements are formatted as plain old JS objects in the console. To make it easier to debug, you can use [jsdom-devtools-formatter](https://github.com/viddo/jsdom-devtools-formatter), which lets you inspect them like real DOM elements. | ||
By default jsdom elements are formatted as plain old JS objects in the console. To make it easier to debug, you can use [jsdom-devtools-formatter](https://github.com/jsdom/jsdom-devtools-formatter), which lets you inspect them like real DOM elements. | ||
@@ -504,2 +502,4 @@ ## Caveats | ||
Some features of jsdom are provided by our dependencies. Notable documentation in that regard includes the list of [supported CSS selectors](https://github.com/dperini/nwsapi/wiki/CSS-supported-selectors) for our CSS selector engine, [`nwsapi`](https://github.com/dperini/nwsapi). | ||
Beyond just features that we haven't gotten to yet, there are two major features that are currently outside the scope of jsdom. These are: | ||
@@ -506,0 +506,0 @@ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
2859681
76463