Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
} else if (cssRules[i].href) {
// @import rule: fetch the resource and evaluate it.
// See http://dev.w3.org/csswg/cssom/#css-import-rule
// If loading of the style sheet fails its cssRules list is simply
// empty. I.e. an @import rule always has an associated style sheet.
const parsed = whatwgURL.parseURL(cssRules[i].href, { baseURL });
if (parsed === null) {
const window = elementImpl._ownerDocument._defaultView;
if (window) {
const error = new Error(`Could not parse CSS @import URL ${cssRules[i].href} relative to base URL ` +
`"${whatwgURL.serializeURL(baseURL)}"`);
error.type = "css @import URL parsing";
window._virtualConsole.emit("jsdomError", error);
}
} else {
fetchStylesheetInternal(elementImpl, whatwgURL.serializeURL(parsed), parsed);
}
}
}
}
} else {
delete frame._contentDocument;
}
}
const parentDoc = frame._ownerDocument;
// https://html.spec.whatwg.org/#process-the-iframe-attributes
let url;
const srcAttribute = getAttributeValue(frame, "src");
if (srcAttribute === "") {
url = parseURL("about:blank");
} else {
url = parseURL(srcAttribute, { baseURL: documentBaseURL(parentDoc) || undefined }) || parseURL("about:blank");
}
const serializedURL = serializeURL(url);
// This is not great, but prevents a require cycle during webidl2js generation
const wnd = new parentDoc._defaultView.constructor({
parsingMode: "html",
url: url.scheme === "javascript" || serializedURL === "about:blank" ? parentDoc.URL : serializedURL,
resourceLoader: parentDoc._customResourceLoader,
userAgent: parentDoc._defaultView.navigator.userAgent,
referrer: parentDoc.URL,
cookieJar: parentDoc._cookieJar,
pool: parentDoc._pool,
encoding: parentDoc._encoding,
agentOptions: parentDoc._agentOptions,
strictSSL: parentDoc._strictSSL,
proxy: parentDoc._proxy,
runScripts: parentDoc._defaultView._runScripts,
commonForOrigin: parentDoc._defaultView._commonForOrigin
exports.reflectURLAttribute = (elementImpl, contentAttributeName) => {
const attributeValue = elementImpl.getAttribute(contentAttributeName);
if (attributeValue === null || attributeValue === "") {
return "";
}
const urlRecord = parseURLToResultingURLRecord(attributeValue, elementImpl._ownerDocument);
if (urlRecord === null) {
return attributeValue;
}
return whatwgURL.serializeURL(urlRecord);
};
get href() {
reinitializeURL(this);
const { url } = this;
if (url === null) {
const href = this.getAttributeNS(null, "href");
return href === null ? "" : href;
}
return whatwgURL.serializeURL(url);
}
function obtainTheResource(el) {
const href = el.getAttribute("href");
if (href === null || href === "") {
return;
}
const url = parseURLToResultingURLRecord(href, el._ownerDocument);
if (url === null) {
return;
}
const serialized = whatwgURL.serializeURL(url);
fetchStylesheet(el, serialized);
}
module.exports.fromURLRecord = urlRecord => {
if (urlRecord.scheme !== "data") {
return null;
}
const input = serializeURL(urlRecord, true).substring("data:".length);
let position = 0;
let mimeType = "";
while (position < input.length && input[position] !== ",") {
mimeType += input[position];
++position;
}
mimeType = stripLeadingAndTrailingASCIIWhitespace(mimeType);
if (position === input.length) {
return null;
}
++position;
_fireEvents(stateChanged, hashChanged, state, oldURL, newURL) {
if (stateChanged) {
fireAnEvent("popstate", this._windowImpl, PopStateEvent, { state });
}
if (hashChanged) {
fireAnEvent("hashchange", this._windowImpl, HashChangeEvent, {
oldURL: whatwgURL.serializeURL(oldURL),
newURL: whatwgURL.serializeURL(newURL)
});
}
}
function updateHref(hheu) {
hheu.setAttributeNS(null, "href", whatwgURL.serializeURL(hheu.url));
}
_fireEvents(stateChanged, hashChanged, state, oldURL, newURL) {
if (stateChanged) {
fireAnEvent("popstate", this._windowImpl, PopStateEvent, { state });
}
if (hashChanged) {
fireAnEvent("hashchange", this._windowImpl, HashChangeEvent, {
oldURL: whatwgURL.serializeURL(oldURL),
newURL: whatwgURL.serializeURL(newURL)
});
}
}