Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@expressen/tallahassee

Package Overview
Dependencies
Maintainers
12
Versions
207
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@expressen/tallahassee - npm Package Compare versions

Comparing version 14.8.0 to 14.9.0

87

index.js

@@ -1,55 +0,54 @@

"use strict";
import { CookieJar, Cookie } from "cookiejar";
const {CookieJar, Cookie} = require("cookiejar");
const {normalizeHeaders} = require("./lib/getHeaders");
const WebPage = require("./lib/WebPage");
import { normalizeHeaders } from "./lib/getHeaders.js";
import WebPage from "./lib/WebPage.js";
const kOrigin = Symbol.for("origin");
module.exports = Tallahassee;
export default class Tallahassee {
constructor(...args) {
let origin, options;
if (typeof args[0] === "object") {
options = args[0];
} else {
origin = args[0];
options = args[1] || {};
}
if (!(this instanceof Tallahassee)) return new Tallahassee(origin, options);
this[kOrigin] = origin;
this.jar = new CookieJar();
this.options = options;
}
function Tallahassee(...args) {
let origin, options;
if (typeof args[0] === "object") {
options = args[0];
} else {
origin = args[0];
options = args[1] || {};
navigateTo(uri, headers = {}, statusCode = 200) {
const webPage = this._getWebPage(headers);
return webPage.navigateTo(uri, webPage.isOriginUrl(uri) && webPage.originRequestHeaders, statusCode);
}
if (!(this instanceof Tallahassee)) return new Tallahassee(origin, options);
this[kOrigin] = origin;
this.jar = new CookieJar();
this.options = options;
}
Tallahassee.prototype.navigateTo = async function navigateTo(uri, headers = {}, statusCode = 200) {
const webPage = this._getWebPage(headers);
return webPage.navigateTo(uri, webPage.isOriginUrl(uri) && webPage.originRequestHeaders, statusCode);
};
load(markup) {
const webPage = this._getWebPage();
const resp = {
text: () => markup,
url: `${webPage.protocol}//${webPage.originHost || "127.0.0.1"}`,
};
return webPage.load(resp);
}
Tallahassee.prototype.load = function load(markup) {
const webPage = this._getWebPage();
const resp = {
text: () => markup,
url: `${webPage.protocol}//${webPage.originHost || "127.0.0.1"}`
};
return webPage.load(resp);
};
_getWebPage(headers) {
const requestHeaders = {
...normalizeHeaders(this.options.headers),
...normalizeHeaders(headers),
};
Tallahassee.prototype._getWebPage = function getWebPage(headers) {
const requestHeaders = {
...normalizeHeaders(this.options.headers),
...normalizeHeaders(headers),
};
const setCookieHeader = requestHeaders["set-cookie"];
if (setCookieHeader) {
for (const cookieStr of Array.isArray(setCookieHeader) ? setCookieHeader : [ setCookieHeader ]) {
const cookie = new Cookie(cookieStr);
this.jar.setCookie(cookie.toString());
}
delete requestHeaders["set-cookie"];
}
const setCookieHeader = requestHeaders["set-cookie"];
if (setCookieHeader) {
for (const cookieStr of Array.isArray(setCookieHeader) ? setCookieHeader : [setCookieHeader]) {
const cookie = new Cookie(cookieStr);
this.jar.setCookie(cookie.toString());
}
delete requestHeaders["set-cookie"];
return new WebPage(this[kOrigin], this.jar, requestHeaders, this.options);
}
return new WebPage(this[kOrigin], this.jar, requestHeaders, this.options);
};
}

@@ -1,6 +0,4 @@

"use strict";
import DOMException from "domexception";
const DOMException = require("domexception");
module.exports = {
export {
btoa,

@@ -24,2 +22,3 @@ atob,

// eslint-disable-next-line no-control-regex
if (/[^\u0000-\u00FF]+/.test(stringToEncode.toString())) throw new DOMException("The string to be encoded contains characters outside of the Latin1 range.");

@@ -26,0 +25,0 @@

@@ -1,9 +0,7 @@

"use strict";
import Node from "./Node.js";
const Node = require("./Node");
const kElm = Symbol.for("element");
const kName = Symbol.for("name");
module.exports = class Attr extends Node {
export default class Attr extends Node {
constructor(document, elm, name) {

@@ -25,2 +23,2 @@ super(document, elm.$elm);

}
};
}

@@ -1,9 +0,8 @@

"use strict";
import vm from "vm";
const Document = require("./Document");
const Fetch = require("./Fetch");
const FormData = require("./FormData");
const Location = require("./Location");
const vm = require("vm");
const Window = require("./Window");
import Document from "./Document.js";
import Fetch from "./Fetch.js";
import FormData from "./FormData.js";
import Location from "./Location.js";
import Window from "./Window.js";

@@ -18,3 +17,3 @@ const webPageSymbol = Symbol.for("webPage");

module.exports = class BrowserTab {
export default class BrowserTab {
constructor(webPage, resp) {

@@ -25,3 +24,3 @@ this[webPageSymbol] = webPage;

this[pendingSymbol] = null;
this[pageOffsetSymbol] = {X: 0, Y: 0};
this[pageOffsetSymbol] = { X: 0, Y: 0 };
this[stuckElementsSymbol] = [];

@@ -54,7 +53,7 @@ this.navigateTo = this.navigateTo.bind(this);

const window = this.window = new Window(resp, {
fetch: Fetch(webPage.fetch.bind(webPage)),
fetch: new Fetch(webPage.fetch.bind(webPage)),
get document() {
return document;
},
...(options?.console && {console})
...(options?.console && { console }),
}, webPage.userAgent, options);

@@ -66,3 +65,3 @@

return window;
}
},
},

@@ -72,4 +71,4 @@ _window: {

return window;
}
}
},
},
});

@@ -133,3 +132,3 @@

if (this.isElementSticky(element)) throw new Error("Cannot scroll to sticky element");
const {height} = element.getBoundingClientRect();
const { height } = element.getBoundingClientRect();
const offsetFromBottom = this.window.innerHeight - height;

@@ -141,3 +140,3 @@ return this.scrollToTopOfElement(element, offsetFromBottom + offset);

const {top} = element.getBoundingClientRect();
const { top } = element.getBoundingClientRect();

@@ -153,7 +152,7 @@ const pageYOffset = this.window.pageYOffset;

const {top, height} = element.getBoundingClientRect();
const { top, height } = element.getBoundingClientRect();
element[originalTopPositionSymbol] = this.window.pageYOffset + top;
element._setBoundingClientRect({
top: 0,
bottom: (height || 0)
bottom: (height || 0),
});

@@ -168,6 +167,6 @@ this[stuckElementsSymbol].push(element);

const top = element[originalTopPositionSymbol] - this.window.pageYOffset;
const {height} = element.getBoundingClientRect();
const { height } = element.getBoundingClientRect();
element._setBoundingClientRect({
top: top,
bottom: height ? top + height : top
top,
bottom: height ? top + height : top,
});

@@ -189,3 +188,3 @@ delete element[originalTopPositionSymbol];

const {target: form, submitter} = event;
const { target: form, submitter } = event;
const method = form.getAttribute("method") || "GET";

@@ -199,3 +198,3 @@ const formaction = (submitter?.getAttribute("formaction")) || form.getAttribute("action");

const uri = new URL(action, this.window.location.origin);
for (const [name, value] of new FormData(form).entries()) {
for (const [ name, value ] of new FormData(form).entries()) {
uri.searchParams.append(name, value);

@@ -211,5 +210,3 @@ }

method: "POST",
headers: {
"Content-Type": "application/x-www-form-urlencoded"
},
headers: { "Content-Type": "application/x-www-form-urlencoded" },
body: payload.toString(),

@@ -227,3 +224,3 @@ });

const pageOffset = this[pageOffsetSymbol];
const {pageXOffset, pageYOffset} = this.window;
const { pageXOffset, pageYOffset } = this.window;
const deltaX = pageOffset.X - pageXOffset;

@@ -234,3 +231,3 @@ const deltaY = pageOffset.Y - pageYOffset;

if (this.isElementSticky(elm)) continue;
const {left, right, top, bottom} = elm.getBoundingClientRect();
const { left, right, top, bottom } = elm.getBoundingClientRect();
elm._setBoundingClientRect({

@@ -247,3 +244,3 @@ left: (left || 0) + deltaX,

}
};
}

@@ -257,3 +254,3 @@ function getLockedWindow(frameSrc) {

get: unauth,
deleteProperty: unauth
deleteProperty: unauth,
});

@@ -260,0 +257,0 @@

@@ -1,7 +0,5 @@

"use strict";
import Node from "./Node.js";
const Node = require("./Node");
export default class Comment extends Node {
module.exports = class Comment extends Node {
};
}

@@ -1,3 +0,1 @@

"use strict";
const prefixNamePattern = /^(-?)(moz|ms|webkit)([A-Z]|\1)/;

@@ -42,7 +40,13 @@

set(target, prop, value) {
if (typeof prop === "symbol") return target[prop] = value;
if (prop in target) return target[prop] = value;
if (typeof prop === "symbol") {
target[prop] = value;
return target[prop];
}
if (prop in target) {
target[prop] = value;
return target[prop];
}
if (value === "" || value === null) value = "";
this.saveStyle({[getStyleName(prop)]: value});
this.saveStyle({ [getStyleName(prop)]: value });
return true;

@@ -54,3 +58,3 @@ }

this.saveStyle({[getStyleName(prop)]: undefined});
this.saveStyle({ [getStyleName(prop)]: undefined });
return true;

@@ -65,3 +69,3 @@ }

if (!Object.keys(styles).length) return this.$elm.removeAttr("style");
const styleValue = Object.entries(styles).reduce((result, [prop, value]) => {
const styleValue = Object.entries(styles).reduce((result, [ prop, value ]) => {
if (value === undefined || value === "") return result;

@@ -89,3 +93,3 @@

module.exports = class CSSStyleDeclaration {
export default class CSSStyleDeclaration {
constructor(element) {

@@ -100,3 +104,3 @@ return new Proxy(this, new CSSStyleDeclarationHandler(element));

}
};
}

@@ -103,0 +107,0 @@ function getStyleName(prop) {

@@ -1,8 +0,7 @@

"use strict";
import DOMException from "domexception";
const DOMException = require("domexception");
const kWindow = Symbol.for("window");
const kElementFactory = Symbol.for("element factory");
module.exports = class CustomElementRegistry {
export default class CustomElementRegistry {
constructor(window) {

@@ -20,2 +19,2 @@ this[kWindow] = window;

}
};
}

@@ -1,14 +0,13 @@

"use strict";
import cheerio from "cheerio";
const { Event } = require("./Events");
const { DOCUMENT_NODE } = require("./nodeTypes");
const cheerio = require("cheerio");
const Comment = require("./Comment");
const DocumentFragment = require("./DocumentFragment");
const DOMImplementation = require("./DOMImplementation");
const ElementFactory = require("./elementFactory");
const HTMLCollection = require("./HTMLCollection");
const Location = require("./Location");
const Node = require("./Node");
const NodeList = require("./NodeList");
import { Event } from "./Events.js";
import { DOCUMENT_NODE } from "./nodeTypes.js";
import Comment from "./Comment.js";
import DocumentFragment from "./DocumentFragment.js";
import DOMImplementation from "./DOMImplementation.js";
import ElementFactory from "./elementFactory.js";
import HTMLCollection from "./HTMLCollection.js";
import Location from "./Location.js";
import Node from "./Node.js";
import NodeList from "./NodeList.js";

@@ -24,5 +23,5 @@ const kCookieJar = Symbol.for("cookieJar");

module.exports = class Document extends Node {
export default class Document extends Node {
constructor(source, cookieJar, window) {
const $ = cheerio.load(source.text || "", {decodeEntities: false});
const $ = cheerio.load(source.text || "", { decodeEntities: false });
super(null, $.root());

@@ -109,5 +108,3 @@ this[windowSymbol] = window;

createTextNode(text) {
return {
textContent: text,
};
return { textContent: text };
}

@@ -151,3 +148,3 @@ createComment(data) {

getElementsByName(name) {
return new HTMLCollection(this.documentElement, `[name="${name}"],#${name}`, {attributes: true});
return new HTMLCollection(this.documentElement, `[name="${name}"],#${name}`, { attributes: true });
}

@@ -167,3 +164,3 @@ importNode(element, deep) {

querySelectorAll(selectors) {
return new NodeList(this.documentElement, selectors, {disconnected: true});
return new NodeList(this.documentElement, selectors, { disconnected: true });
}

@@ -187,2 +184,2 @@ _getElement($elm) {

}
};
}

@@ -1,6 +0,5 @@

"use strict";
import cheerio from "cheerio";
const cheerio = require("cheerio");
const Node = require("./Node");
const {DOCUMENT_FRAGMENT_NODE} = require("./nodeTypes");
import Node from "./Node.js";
import { DOCUMENT_FRAGMENT_NODE } from "./nodeTypes.js";

@@ -11,5 +10,5 @@ const dollarSymbol = Symbol.for("$");

module.exports = class DocumentFragment extends Node {
export default class DocumentFragment extends Node {
constructor(document, templateElement) {
const $ = cheerio.load("", {decodeEntities: false});
const $ = cheerio.load("", { decodeEntities: false });
const $body = $("body");

@@ -19,3 +18,3 @@ if (templateElement) {

templateElement.$elm.contents().each((_, elm) => {
content += $.html(elm, {decodeEntities: true});
content += $.html(elm, { decodeEntities: true });
});

@@ -50,3 +49,3 @@ $body.html(content);

clone(deep) {
return new DocumentFragment(this.ownerDocument, deep && {$elm: this[bodySymbol]});
return new DocumentFragment(this.ownerDocument, deep && { $elm: this[bodySymbol] });
}

@@ -73,6 +72,6 @@ querySelector(selector) {

this.$elm.contents().each((_, elm) => {
content += $.html(elm, {decodeEntities: true});
content += $.html(elm, { decodeEntities: true });
});
return content;
}
};
}

@@ -1,9 +0,7 @@

"use strict";
import Node from "./Node.js";
const Node = require("./Node");
module.exports = class DocumentType extends Node {
export default class DocumentType extends Node {
get nodeType() {
return 10;
}
};
}

@@ -1,7 +0,5 @@

"use strict";
const documentSymbol = Symbol.for("document");
const cookieJarSymbol = Symbol.for("cookieJar");
module.exports = class DOMImplementation {
export default class DOMImplementation {
constructor(document) {

@@ -14,6 +12,6 @@ this[documentSymbol] = document;

return new Document(
{text: `<!doctype html><html><head><title>${title}</title></head><body></body></html>`},
ownerDocument[cookieJarSymbol],
{ text: `<!doctype html><html><head><title>${title}</title></head><body></body></html>` },
ownerDocument[cookieJarSymbol]
);
}
};
}

@@ -1,3 +0,1 @@

"use strict";
class DOMStringMapHandler {

@@ -54,7 +52,7 @@ constructor(element) {

module.exports = class DOMStringMap {
export default class DOMStringMap {
constructor(element) {
return new Proxy(this, new DOMStringMapHandler(element));
}
};
}

@@ -66,3 +64,3 @@ function getObjectKey(name) {

function getAttributeName(prop) {
return "data-" + prop.replace(/[A-Z]/g, (g) => `-${g[0].toLowerCase()}`);
return `data-${prop.replace(/[A-Z]/g, (g) => `-${g[0].toLowerCase()}`)}`;
}

@@ -1,7 +0,5 @@

"use strict";
const elementSymbol = Symbol.for("element");
const emitterSymbol = Symbol.for("emitter");
module.exports = class DOMTokenList {
export default class DOMTokenList {
constructor(element) {

@@ -44,2 +42,2 @@ this[elementSymbol] = element;

}
};
}

@@ -1,15 +0,14 @@

"use strict";
import DOMException from "domexception";
import vm from "vm";
const { DOCUMENT_FRAGMENT_NODE, TEXT_NODE } = require("./nodeTypes");
const { Event, PointerEvent } = require("./Events");
const { getElementsByClassName, getElementsByTagName } = require("./getElements");
const Attr = require("./Attr");
const CSSStyleDeclaration = require("./CSSStyleDeclaration");
const DOMException = require("domexception");
const DOMTokenList = require("./DOMTokenList");
const HTMLCollection = require("./HTMLCollection");
const Node = require("./Node");
const NodeList = require("./NodeList");
const eventnames = require("./eventnames");
const vm = require("vm");
import { DOCUMENT_FRAGMENT_NODE, TEXT_NODE } from "./nodeTypes.js";
import { Event, PointerEvent } from "./Events.js";
import { getElementsByClassName, getElementsByTagName } from "./getElements.js";
import Attr from "./Attr.js";
import CSSStyleDeclaration from "./CSSStyleDeclaration.js";
import DOMTokenList from "./DOMTokenList.js";
import HTMLCollection from "./HTMLCollection.js";
import Node from "./Node.js";
import NodeList from "./NodeList.js";
import eventnames from "./eventnames.js";

@@ -21,3 +20,3 @@ const classListSymbol = Symbol.for("classList");

module.exports = class Element extends Node {
export default class Element extends Node {
constructor(document, $elm) {

@@ -32,3 +31,3 @@ super(document, $elm);

height: 0,
width: 0
width: 0,
};

@@ -38,3 +37,3 @@

this[scrolledSymbol] = {left: 0, top: 0};
this[scrolledSymbol] = { left: 0, top: 0 };
this[classListSymbol] = new DOMTokenList(this);

@@ -44,8 +43,8 @@ this[stylesSymbol] = new CSSStyleDeclaration(this);

if ($elm[0].attribs) {
for (const [name, value] of Object.entries($elm[0].attribs)) {
for (const [ name, value ] of Object.entries($elm[0].attribs)) {
if (name.indexOf("on") !== 0) continue;
if (eventnames.indexOf(name.substring(2)) === -1) continue;
const contextExtensions = [this];
const contextExtensions = [ this ];
if (document?.defaultView) contextExtensions.push(document.defaultView);
this[name] = vm.compileFunction(value, ["event"], { contextExtensions });
this[name] = vm.compileFunction(value, [ "event" ], { contextExtensions });
}

@@ -67,3 +66,3 @@ }

const entries = Object.entries(attr);
const obj = entries.reduce((acc, [name], idx) => {
const obj = entries.reduce((acc, [ name ], idx) => {
const attrib = new Attr(this.ownerDocument, this, name);

@@ -73,5 +72,3 @@ acc[idx] = attrib;

return acc;
}, {
length: entries.length
});
}, { length: entries.length });
return obj;

@@ -169,3 +166,3 @@ }

this.setAttribute("src", value);
this.dispatchEvent(new Event("load", {bubbles: true}));
this.dispatchEvent(new Event("load", { bubbles: true }));
}

@@ -181,3 +178,3 @@ get href() {

this.setAttribute("href", value);
this.dispatchEvent(new Event("load", {bubbles: true}));
this.dispatchEvent(new Event("load", { bubbles: true }));
}

@@ -306,3 +303,3 @@ get open() {

querySelectorAll(selectors) {
return new NodeList(this, selectors, {disconnected: true});
return new NodeList(this, selectors, { disconnected: true });
}

@@ -426,3 +423,3 @@ insertAdjacentHTML(position, markup) {

for (const axis in axes) {
if (axes.hasOwnProperty(axis)) {
if (Object.hasOwnProperty.call(axes, axis)) {
this[rectsSymbol][axis] = axes[axis];

@@ -452,6 +449,6 @@ }

elms.slice().forEach((elm) => {
const {left, right} = elm.getBoundingClientRect();
const { left, right } = elm.getBoundingClientRect();
elm._setBoundingClientRect({
left: (left || 0) + delta,
right: (right || 0) + delta
right: (right || 0) + delta,
});

@@ -464,9 +461,9 @@ });

elms.slice().forEach((elm) => {
const {top, bottom} = elm.getBoundingClientRect();
const { top, bottom } = elm.getBoundingClientRect();
elm._setBoundingClientRect({
top: (top || 0) + delta,
bottom: (bottom || 0) + delta
bottom: (bottom || 0) + delta,
});
});
}
};
}

@@ -1,71 +0,69 @@

"use strict";
import DocumentType from "./DocumentType.js";
import HTMLElement from "./HTMLElement.js";
import HTMLAnchorElement from "./HTMLAnchorElement.js";
import HTMLButtonElement from "./HTMLButtonElement.js";
import HTMLDialogElement from "./HTMLDialogElement.js";
import HTMLFieldSetElement from "./HTMLFieldSetElement.js";
import HTMLLegendElement from "./HTMLLegendElement.js";
import HTMLFormElement from "./HTMLFormElement.js";
import HTMLInputElement from "./HTMLInputElement.js";
import HTMLOptionElement from "./HTMLOptionElement.js";
import HTMLScriptElement from "./HTMLScriptElement.js";
import HTMLSelectElement from "./HTMLSelectElement.js";
import HTMLTemplateElement from "./HTMLTemplateElement.js";
import HTMLTextAreaElement from "./HTMLTextAreaElement.js";
import HTMLImageElement from "./HTMLImageElement.js";
import HTMLIFrameElement from "./HTMLIFrameElement.js";
import HTMLVideoElement from "./HTMLVideoElement.js";
import Text from "./Text.js";
import { TEXT_NODE } from "./nodeTypes.js";
const DocumentType = require("./DocumentType");
const HTMLElement = require("./HTMLElement");
const HTMLAnchorElement = require("./HTMLAnchorElement");
const HTMLButtonElement = require("./HTMLButtonElement");
const HTMLDialogElement = require("./HTMLDialogElement");
const HTMLFieldSetElement = require("./HTMLFieldSetElement");
const HTMLLegendElement = require("./HTMLLegendElement");
const HTMLFormElement = require("./HTMLFormElement");
const HTMLInputElement = require("./HTMLInputElement");
const HTMLOptionElement = require("./HTMLOptionElement");
const HTMLScriptElement = require("./HTMLScriptElement");
const HTMLSelectElement = require("./HTMLSelectElement");
const HTMLTemplateElement = require("./HTMLTemplateElement");
const HTMLTextAreaElement = require("./HTMLTextAreaElement");
const HTMLImageElement = require("./HTMLImageElement");
const HTMLIFrameElement = require("./HTMLIFrameElement");
const HTMLVideoElement = require("./HTMLVideoElement");
const Text = require("./Text");
const {TEXT_NODE} = require("./nodeTypes");
export default class ElementFactory {
constructor(document) {
this.document = document;
this.definitions = {
a: HTMLAnchorElement,
button: HTMLButtonElement,
dialog: HTMLDialogElement,
fieldset: HTMLFieldSetElement,
legend: HTMLLegendElement,
img: HTMLImageElement,
iframe: HTMLIFrameElement,
form: HTMLFormElement,
input: HTMLInputElement,
video: HTMLVideoElement,
template: HTMLTemplateElement,
textarea: HTMLTextAreaElement,
script: HTMLScriptElement,
select: HTMLSelectElement,
option: HTMLOptionElement,
"!doctype": DocumentType,
};
this.custom = {};
}
module.exports = ElementFactory;
create($elm) {
const nodeType = $elm[0].nodeType;
const document = this.document;
if (nodeType === TEXT_NODE) return new Text(document, $elm);
const tagName = ($elm[0]?.name || "").toLowerCase();
const definitions = this.definitions;
if (tagName in definitions) return new definitions[tagName](document, $elm);
const custom = this.custom;
if (tagName in custom) {
const elm = new custom[tagName](document, $elm);
if (elm.connectedCallback) elm.connectedCallback();
return elm;
}
function ElementFactory(document) {
this.document = document;
this.definitions = {
a: HTMLAnchorElement,
button: HTMLButtonElement,
dialog: HTMLDialogElement,
fieldset: HTMLFieldSetElement,
legend: HTMLLegendElement,
img: HTMLImageElement,
iframe: HTMLIFrameElement,
form: HTMLFormElement,
input: HTMLInputElement,
video: HTMLVideoElement,
template: HTMLTemplateElement,
textarea: HTMLTextAreaElement,
script: HTMLScriptElement,
select: HTMLSelectElement,
option: HTMLOptionElement,
"!doctype": DocumentType,
};
this.custom = {};
}
return new HTMLElement(document, $elm);
}
ElementFactory.prototype.create = function define($elm) {
const nodeType = $elm[0].nodeType;
const document = this.document;
if (nodeType === TEXT_NODE) return new Text(document, $elm);
const tagName = ($elm[0]?.name || "").toLowerCase();
const definitions = this.definitions;
if (tagName in definitions) return new definitions[tagName](document, $elm);
const custom = this.custom;
if (tagName in custom) {
const elm = new custom[tagName](document, $elm);
if (elm.connectedCallback) elm.connectedCallback();
return elm;
define(tagName, TagClass) {
this.custom[tagName] = TagClass;
}
return new HTMLElement(document, $elm);
};
ElementFactory.prototype.define = function define(tagName, TagClass) {
this.custom[tagName] = TagClass;
};
ElementFactory.prototype.get = function get(name) {
return this.custom[name];
};
get(name) {
return this.custom[name];
}
}

@@ -1,4 +0,2 @@

"use strict";
module.exports = [
export default [
"abort",

@@ -5,0 +3,0 @@ "autocomplete",

@@ -1,3 +0,1 @@

"use strict";
const cancelBubbleSymbol = Symbol.for("cancelBubble");

@@ -10,3 +8,3 @@ const defaultPreventedSymbol = Symbol.for("defaultPrevented");

class Event {
constructor(type = "", {bubbles} = {bubbles: false}) {
constructor(type = "", { bubbles } = { bubbles: false }) {
this[defaultPreventedSymbol] = false;

@@ -56,3 +54,3 @@ this[cancelBubbleSymbol] = false;

class SubmitEvent extends Event {
constructor(type, options = {bubbles: true}) {
constructor(type, options = { bubbles: true }) {
super(type, options);

@@ -81,3 +79,3 @@ this[kSubmitter] = undefined;

constructor(type) {
super(type, {bubbles: true});
super(type, { bubbles: true });
}

@@ -90,3 +88,3 @@ }

constructor(type, options = {}) {
super(type, {bubbles: true});
super(type, { bubbles: true });

@@ -97,3 +95,5 @@ this.key = options.key;

module.exports = {
const symbols = { submitter: kSubmitter };
export {
Event,

@@ -106,5 +106,3 @@ CustomEvent,

KeyboardEvent,
symbols: {
submitter: kSubmitter,
},
symbols,
};

@@ -1,9 +0,7 @@

"use strict";
import { EventEmitter } from "events";
const {EventEmitter} = require("events");
const kEmitter = Symbol.for("emitter");
const kListeners = Symbol.for("listeners");
module.exports = class EventTarget {
export default class EventTarget {
constructor() {

@@ -19,3 +17,3 @@ const emitter = this[kEmitter] = new EventEmitter();

const self = this;
const config = [name, fn, usesCapture(options), boundFn];
const config = [ name, fn, usesCapture(options), boundFn ];
const existingListenerIndex = self._getExistingIndex(...config);

@@ -72,3 +70,3 @@ if (existingListenerIndex !== -1) return;

}
};
}

@@ -75,0 +73,0 @@ function usesCapture(options) {

@@ -1,22 +0,22 @@

"use strict";
export default class Fetch {
constructor(browserFetch) {
const stack = [];
module.exports = function Fetch(browserFetch) {
const stack = [];
function fetch(...args) {
const request = browserFetch(...args);
function fetch(...args) {
const request = browserFetch(...args);
const stackedProm = request.then(() => {
stack.pop();
}).catch(() => {
stack.pop();
});
stack.push(stackedProm);
const stackedProm = request.then(() => {
stack.pop();
}).catch(() => {
stack.pop();
});
stack.push(stackedProm);
return request;
}
return request;
fetch._pendingRequests = stack;
return fetch;
}
fetch._pendingRequests = stack;
return fetch;
};
}

@@ -1,6 +0,4 @@

"use strict";
const kForm = Symbol.for("form");
module.exports = class FormData {
export default class FormData {
constructor(form) {

@@ -43,2 +41,2 @@ if (form && form.tagName !== "FORM") throw new TypeError("Failed to construct 'FormData': parameter 1 is not of type 'HTMLFormElement'");

}
};
}

@@ -1,6 +0,4 @@

"use strict";
import HTMLCollection from "./HTMLCollection.js";
const HTMLCollection = require("./HTMLCollection");
module.exports = {
export {
getElementsByClassName,

@@ -18,3 +16,3 @@ getElementsByTagName,

}, "");
return new HTMLCollection(parentElement, selector, {attributes: true});
return new HTMLCollection(parentElement, selector, { attributes: true });
}

@@ -24,3 +22,3 @@

const selector = tagName && tagName.trim().match(/^([_a-zA-Z]+[_a-zA-Z0-9-]*)$/)[1];
return new HTMLCollection(parentElement, selector, {attributes: false});
return new HTMLCollection(parentElement, selector, { attributes: false });
}

@@ -1,4 +0,2 @@

"use strict";
module.exports = {
export {
normalizeHeaders,

@@ -5,0 +3,0 @@ getLocationHost,

@@ -1,5 +0,3 @@

"use strict";
import { PopStateEvent } from "./Events.js";
const { PopStateEvent } = require("./Events");
const windowSymbol = Symbol.for("window");

@@ -9,6 +7,6 @@ const historyStatesSymbol = Symbol.for("historyStates");

module.exports = class History {
export default class History {
constructor(window, location) {
this[windowSymbol] = window;
this[historyStatesSymbol] = [{ state: null, url: new URL(location.toString()) }];
this[historyStatesSymbol] = [ { state: null, url: new URL(location.toString()) } ];
this[currentHistoryStateSymbol] = 0;

@@ -20,3 +18,3 @@ }

as: url.pathname,
idx: this[currentHistoryStateSymbol]
idx: this[currentHistoryStateSymbol],
};

@@ -74,2 +72,2 @@ }

}
};
}

@@ -1,8 +0,6 @@

"use strict";
import HTMLElement from "./HTMLElement.js";
const HTMLElement = require("./HTMLElement");
const urlSymbol = Symbol.for("href");
module.exports = class HTMLAnchorElement extends HTMLElement {
export default class HTMLAnchorElement extends HTMLElement {
get href() {

@@ -48,3 +46,3 @@ return hrefPropertyGetter(this[urlSymbol], "href");

}
};
}

@@ -51,0 +49,0 @@ function hrefPropertyGetter(url, propertyName) {

@@ -1,7 +0,5 @@

"use strict";
import { PointerEvent } from "./Events.js";
import HTMLElement from "./HTMLElement.js";
const { PointerEvent } = require("./Events");
const HTMLElement = require("./HTMLElement");
module.exports = class HTMLButtonElement extends HTMLElement {
export default class HTMLButtonElement extends HTMLElement {
constructor(document, $elm) {

@@ -53,2 +51,2 @@ super(document, $elm);

}
};
}

@@ -1,6 +0,4 @@

"use strict";
import NodeList from "./NodeList.js";
const NodeList = require("./NodeList");
module.exports = class HTMLCollection extends NodeList {
export default class HTMLCollection extends NodeList {
constructor(parentElement, selector, options = { attributes: true }) {

@@ -10,10 +8,6 @@ super(parentElement, selector, { ...options });

Object.defineProperties(this, {
item: {
enumerable: true,
},
namedItem: {
enumerable: true,
},
item: { enumerable: true },
namedItem: { enumerable: true },
});
}
};
}

@@ -1,7 +0,5 @@

"use strict";
import { Event } from "./Events.js";
import HTMLElement from "./HTMLElement.js";
const { Event } = require("./Events");
const HTMLElement = require("./HTMLElement");
module.exports = class HTMLDialogElement extends HTMLElement {
export default class HTMLDialogElement extends HTMLElement {
constructor(document, $elm) {

@@ -25,2 +23,2 @@ super(document, $elm);

}
};
}

@@ -1,10 +0,8 @@

"use strict";
import Element from "./Element.js";
import DOMStringMap from "./DOMStringMap.js";
import { Event } from "./Events.js";
const Element = require("./Element");
const DOMStringMap = require("./DOMStringMap");
const { Event } = require("./Events");
const datasetSymbol = Symbol.for("dataset");
module.exports = class HTMLElement extends Element {
export default class HTMLElement extends Element {
constructor(document, $elm) {

@@ -34,2 +32,2 @@ super(document, $elm);

}
};
}

@@ -1,9 +0,7 @@

"use strict";
import HTMLElement from "./HTMLElement.js";
const HTMLElement = require("./HTMLElement");
module.exports = class HTMLFieldSetElement extends HTMLElement {
export default class HTMLFieldSetElement extends HTMLElement {
get form() {
return this.closest("form");
}
};
}

@@ -1,7 +0,5 @@

"use strict";
import HTMLCollection from "./HTMLCollection.js";
import RadioNodeList from "./RadioNodeList.js";
const HTMLCollection = require("./HTMLCollection");
const RadioNodeList = require("./RadioNodeList");
module.exports = class HTMLFormControlsCollection extends HTMLCollection {
export default class HTMLFormControlsCollection extends HTMLCollection {
constructor(parentElement, selector) {

@@ -29,5 +27,5 @@ super(parentElement, selector, { childList: true, attributes: true });

return namedElement;
}
},
});
}
};
}

@@ -1,12 +0,10 @@

"use strict";
import { Event, SubmitEvent, symbols } from "./Events.js";
import HTMLElement from "./HTMLElement.js";
import HTMLFormControlsCollection from "./HTMLFormControlsCollection.js";
import HTMLInputElement from "./HTMLInputElement.js";
import HTMLSelectElement from "./HTMLSelectElement.js";
const { Event, SubmitEvent, symbols } = require("./Events");
const HTMLElement = require("./HTMLElement");
const HTMLFormControlsCollection = require("./HTMLFormControlsCollection");
const HTMLInputElement = require("./HTMLInputElement");
const HTMLSelectElement = require("./HTMLSelectElement");
const originSymbol = Symbol.for("origin");
module.exports = class HTMLFormElement extends HTMLElement {
export default class HTMLFormElement extends HTMLElement {
constructor(document, $elm) {

@@ -24,3 +22,3 @@ super(document, $elm);

set method(val) {
const validMethods = ["get", "post"];
const validMethods = [ "get", "post" ];
if (typeof val === "string" && validMethods.includes(val.toLowerCase())) {

@@ -92,3 +90,3 @@ const method = val.toLowerCase();

reportValidity() {
return [...this.elements]
return [ ...this.elements ]
.map((el) => {

@@ -104,2 +102,2 @@ if (el instanceof HTMLInputElement) {

}
};
}

@@ -1,8 +0,6 @@

"use strict";
import HTMLElement from "./HTMLElement.js";
const HTMLElement = require("./HTMLElement");
const documentSymbol = Symbol.for("document");
module.exports = class HTMLIFrameElement extends HTMLElement {
export default class HTMLIFrameElement extends HTMLElement {
constructor(document, $elm) {

@@ -21,2 +19,2 @@ super(document, $elm);

}
};
}

@@ -1,6 +0,4 @@

"use strict";
import HTMLElement from "./HTMLElement.js";
const HTMLElement = require("./HTMLElement");
module.exports = class HTMLImageElement extends HTMLElement {
export default class HTMLImageElement extends HTMLElement {
constructor(document, $elm) {

@@ -37,2 +35,2 @@ super(document, $elm);

}
};
}

@@ -1,7 +0,5 @@

"use strict";
import { Event, InputEvent, PointerEvent } from "./Events.js";
import HTMLElement from "./HTMLElement.js";
import ValidityState from "./ValidityState.js";
const { Event, InputEvent, PointerEvent } = require("./Events");
const HTMLElement = require("./HTMLElement");
const ValidityState = require("./ValidityState");
const kValidity = Symbol.for("validity");

@@ -11,3 +9,3 @@ const kValidationMessage = Symbol.for("validation message");

module.exports = class HTMLInputElement extends HTMLElement {
export default class HTMLInputElement extends HTMLElement {
constructor(...args) {

@@ -173,3 +171,3 @@ super(...args);

} else {
this[kFiles] = [file];
this[kFiles] = [ file ];
}

@@ -187,2 +185,2 @@ changed = true;

}
};
}

@@ -1,9 +0,7 @@

"use strict";
import HTMLElement from "./HTMLElement.js";
const HTMLElement = require("./HTMLElement");
module.exports = class HTMLLegendElement extends HTMLElement {
export default class HTMLLegendElement extends HTMLElement {
get form() {
return this.closest("form");
}
};
}

@@ -1,7 +0,5 @@

"use strict";
import HTMLElement from "./HTMLElement.js";
import { Event } from "./Events.js";
const HTMLElement = require("./HTMLElement");
const {Event} = require("./Events");
module.exports = class HTMLOptionElement extends HTMLElement {
export default class HTMLOptionElement extends HTMLElement {
get selected() {

@@ -40,2 +38,2 @@ return this.$elm.prop("selected");

}
};
}

@@ -1,11 +0,9 @@

"use strict";
import NodeList from "./NodeList.js";
const NodeList = require("./NodeList");
const kSelectedIndex = Symbol.for("selected index");
const kLiveList = Symbol.for("liveList");
module.exports = class HTMLOptionCollection extends NodeList {
export default class HTMLOptionCollection extends NodeList {
constructor(parentElement) {
super(parentElement, "> option", {attributes: false});
super(parentElement, "> option", { attributes: false });
if (!this.length) this[kSelectedIndex] = -1;

@@ -30,7 +28,10 @@ else this[kSelectedIndex] = parentElement.multiple ? -1 : 0;

}
if (!match) return this[kSelectedIndex] = -1;
if (!match) {
this[kSelectedIndex] = -1;
return this[kSelectedIndex];
}
return value;
}
},
});
}
};
}

@@ -1,7 +0,6 @@

"use strict";
import vm from "vm";
const HTMLElement = require("./HTMLElement");
const vm = require("vm");
import HTMLElement from "./HTMLElement.js";
module.exports = class HTMLScriptElement extends HTMLElement {
export default class HTMLScriptElement extends HTMLElement {
get textContent() {

@@ -18,2 +17,2 @@ return this.$elm.html();

}
};
}

@@ -1,9 +0,7 @@

"use strict";
import { Event } from "./Events.js";
import HTMLElement from "./HTMLElement.js";
import HTMLCollection from "./HTMLCollection.js";
import HtmlOptionCollection from "./HTMLOptionsCollection.js";
import ValidityState from "./ValidityState.js";
const { Event } = require("./Events");
const HTMLElement = require("./HTMLElement");
const HTMLCollection = require("./HTMLCollection");
const HtmlOptionCollection = require("./HTMLOptionsCollection");
const ValidityState = require("./ValidityState");
const kValidity = Symbol.for("validity");

@@ -14,3 +12,3 @@ const kValidationMessage = Symbol.for("validation message");

module.exports = class HTMLSelectElement extends HTMLElement {
export default class HTMLSelectElement extends HTMLElement {
constructor(...args) {

@@ -113,2 +111,2 @@ super(...args);

}
};
}

@@ -1,10 +0,8 @@

"use strict";
import HTMLElement from "./HTMLElement.js";
import DocumentFragment from "./DocumentFragment.js";
const HTMLElement = require("./HTMLElement");
module.exports = class HTMLTemplateElement extends HTMLElement {
export default class HTMLTemplateElement extends HTMLElement {
get content() {
const DocumentFragment = require("./DocumentFragment");
return new DocumentFragment(this.ownerDocument, this);
}
};
}

@@ -1,7 +0,5 @@

"use strict";
import { InputEvent } from "./Events.js";
import HTMLElement from "./HTMLElement.js";
const { InputEvent } = require("./Events");
const HTMLElement = require("./HTMLElement");
module.exports = class HTMLTextAreaElement extends HTMLElement {
export default class HTMLTextAreaElement extends HTMLElement {
get disabled() {

@@ -43,2 +41,2 @@ return this.$elm.prop("disabled");

}
};
}

@@ -1,6 +0,4 @@

"use strict";
import HTMLElement from "./HTMLElement.js";
const HTMLElement = require("./HTMLElement");
module.exports = class HTMLVideoElement extends HTMLElement {
export default class HTMLVideoElement extends HTMLElement {
constructor(document, $elm) {

@@ -17,2 +15,2 @@ super(document, $elm);

}
};
}

@@ -1,11 +0,9 @@

"use strict";
import Document from "./Document.js";
import IntersectionObserver from "./IntersectionObserver.js";
import MutationObserver from "./MutationObserver.js";
import Storage from "./Storage.js";
import Window from "./Window.js";
import HTMLCollection from "./HTMLCollection.js";
const Document = require("./Document");
const IntersectionObserver = require("./IntersectionObserver");
const MutationObserver = require("./MutationObserver");
const Storage = require("./Storage");
const Window = require("./Window");
const {HTMLCollection} = require("./HTMLCollection");
module.exports = {
export {
Document,

@@ -16,3 +14,3 @@ HTMLCollection,

Window,
Storage
Storage,
};

@@ -1,11 +0,9 @@

"use strict";
module.exports = {
export {
getRootMargin,
getIntersectionRatio,
getIsIntersecting
getIsIntersecting,
};
function getRootMargin({rootMargin = ""} = {}) {
const [top, right, bottom, left] = rootMargin
function getRootMargin({ rootMargin = "" } = {}) {
const [ top, right, bottom, left ] = rootMargin
.split(" ")

@@ -18,3 +16,3 @@ .map((num) => parseInt(num));

bottom: firstOf(bottom, top),
left: firstOf(left, right, top)
left: firstOf(left, right, top),
};

@@ -34,4 +32,4 @@ }

function getIntersectionRatio(boundingClientRect, windowInnerHeight, rootMargin = {}) {
const {top, height, bottom = top + height} = boundingClientRect;
const {top: marginTop, bottom: marginBottom} = rootMargin;
const { top, height, bottom = top + height } = boundingClientRect;
const { top: marginTop, bottom: marginBottom } = rootMargin;

@@ -38,0 +36,0 @@ const topIntersection = -(marginTop || 0);

@@ -1,69 +0,69 @@

"use strict";
import { getRootMargin } from "./intersectionCalc.js";
import fakeIntersectionObserverEntry from "./intersectionObserverEntry.js";
const { getRootMargin, getIntersectionRatio, getIsIntersecting } = require("./intersectionCalc");
const IntersectionObserverEntry = require("./intersectionObserverEntry");
const kToObserve = Symbol.for("toObserve");
const kPrevEntries = Symbol.for("previousEntries");
const kNewObserv = Symbol.for("newObservables");
const kUpdate = Symbol.for("viewportUpdate");
const kRootMargin = Symbol.for("rootMargin");
module.exports = function FakeIntersectionObserver(browser) {
const observed = [];
export default function fakeIntersectionObserver(browser) {
let observed = [];
IntersectionObserver._getObserved = function () {
return observed;
};
const IntersectionObserverEntry = fakeIntersectionObserverEntry(browser);
browser.window.IntersectionObserverEntry = IntersectionObserverEntry;
const intersectionObserverEntry = IntersectionObserverEntry(browser);
intersectionObserverEntry.prototype.intersectionRatio = getIntersectionRatio;
intersectionObserverEntry.prototype.isIntersecting = getIsIntersecting;
browser.window.IntersectionObserverEntry = intersectionObserverEntry;
class IntersectionObserver {
constructor(viewportUpdate, options) {
this[kToObserve] = [];
this[kPrevEntries] = [];
this[kNewObserv] = [];
this[kUpdate] = viewportUpdate;
this[kRootMargin] = getRootMargin(options);
return IntersectionObserver;
browser.window.addEventListener("scroll", () => {
const entries = this[kToObserve].map((el) => new IntersectionObserverEntry(el, this[kRootMargin]));
const changedEntries = entries.filter((entry) => {
const previous = this[kPrevEntries].find((x) => x.target === entry.target);
if (!previous) return true;
return entry.intersectionRatio !== previous.intersectionRatio;
});
if (changedEntries.length > 0) {
viewportUpdate(changedEntries);
}
function IntersectionObserver(viewPortUpdate, options) {
let toObserve = [];
let previousEntries = [];
let newObservables = [];
const rootMargin = getRootMargin(options);
browser.window.addEventListener("scroll", onScroll);
this[kPrevEntries] = entries;
});
}
return {
disconnect() {
toObserve = [];
previousEntries = [];
},
observe(element) {
toObserve.push(element);
observed.push(element);
newObservables.push(element);
process.nextTick(onObserve);
},
unobserve(element) {
toObserve = toObserve.filter((item) => item !== element);
newObservables = newObservables.filter((item) => item !== element);
}
};
function onObserve() {
if (!newObservables.length) return;
const newEntries = newObservables.map((el) => intersectionObserverEntry(el, rootMargin));
newObservables = [];
viewPortUpdate(newEntries);
previousEntries = previousEntries.concat(newEntries);
disconnect() {
this[kToObserve] = [];
this[kPrevEntries] = [];
}
function onScroll() {
const entries = toObserve.map((el) => intersectionObserverEntry(el, rootMargin));
const changedEntries = entries.filter(hasChanged);
if (changedEntries.length > 0) {
viewPortUpdate(changedEntries);
}
observe(element) {
this[kToObserve].push(element);
observed.push(element);
this[kNewObserv].push(element);
process.nextTick(() => {
if (!this[kNewObserv].length) return;
previousEntries = entries;
const newEntries = this[kNewObserv].map((el) => new IntersectionObserverEntry(el, this[kRootMargin]));
this[kNewObserv] = [];
this[kUpdate](newEntries);
this[kPrevEntries] = this[kPrevEntries].concat(newEntries);
});
}
function hasChanged(entry) {
const previous = previousEntries.find((x) => x.target === entry.target);
if (!previous) return true;
return entry.intersectionRatio !== previous.intersectionRatio;
unobserve(element) {
observed = this[kToObserve] = this[kToObserve].filter((item) => item !== element);
this[kNewObserv] = this[kNewObserv].filter((item) => item !== element);
}
}
};
IntersectionObserver._getObserved = function () {
return observed;
};
return IntersectionObserver;
}

@@ -1,15 +0,13 @@

"use strict";
import { getIntersectionRatio, getIsIntersecting } from "./intersectionCalc.js";
const {getIntersectionRatio, getIsIntersecting} = require("./intersectionCalc");
export default function fakeIntersectionObserverEntry(browser) {
return class IntersectionObserverEntry {
constructor(element, rootMargin) {
const boundingClientRect = element.getBoundingClientRect();
const intersectionRatio = getIntersectionRatio(boundingClientRect, browser.window.innerHeight, rootMargin);
const isIntersecting = getIsIntersecting(intersectionRatio);
module.exports = function FakeIntersectionObserverEntry(browser) {
return IntersectionObserverEntry;
function IntersectionObserverEntry(element, rootMargin) {
const boundingClientRect = element.getBoundingClientRect();
const intersectionRatio = getIntersectionRatio(boundingClientRect, browser.window.innerHeight, rootMargin);
const isIntersecting = getIsIntersecting(intersectionRatio);
return {target: element, boundingClientRect, intersectionRatio, isIntersecting};
}
};
return { target: element, boundingClientRect, intersectionRatio, isIntersecting };
}
};
}

@@ -1,7 +0,5 @@

"use strict";
const parentSymbol = Symbol.for("parent");
const emitterSymbol = Symbol.for("emitter");
module.exports = class Location extends URL {
export default class Location extends URL {
constructor(parent, url = "/", origin = "https://localhost:3000") {

@@ -22,3 +20,4 @@ super(url, origin);

if (url.startsWith("#")) {
return this.hash = url;
this.hash = url;
return url;
}

@@ -37,2 +36,2 @@ const oldHref = this.toString();

}
};
}

@@ -1,5 +0,3 @@

"use strict";
import EventTarget from "./EventTarget.js";
const EventTarget = require("./EventTarget");
const kWindow = Symbol.for("window");

@@ -10,3 +8,3 @@ const kMedia = Symbol.for("media");

module.exports = class MediaQueryList extends EventTarget {
export default class MediaQueryList extends EventTarget {
constructor(window, mediaQuery, overrideMatchMedia) {

@@ -52,3 +50,3 @@ if (mediaQuery === undefined) throw new TypeError("Failed to execute 'matchMedia' on 'Window': 1 argument required, but only 0 present.");

const condition = conditions[i];
const [prop, value] = condition.split(":");
const [ prop, value ] = condition.split(":");

@@ -74,2 +72,2 @@ if (prop.startsWith("min")) {

}
};
}

@@ -1,3 +0,1 @@

"use strict";
const emitterSymbol = Symbol.for("emitter");

@@ -7,3 +5,3 @@ const nodeSymbol = Symbol.for("node");

class MutationObserver {
export default class MutationObserver {
constructor(callback) {

@@ -31,13 +29,11 @@ this[callbackSymbol] = callback;

_onMutation() {
return this[callbackSymbol].call(this, [MutationRecord("childList")]);
return this[callbackSymbol].call(this, [ mutationRecord("childList") ]);
}
_onAttributeChange(attributeName, target) {
return this[callbackSymbol].call(this, [MutationRecord("attributes", {attributeName, target})]);
return this[callbackSymbol].call(this, [ mutationRecord("attributes", { attributeName, target }) ]);
}
}
module.exports = MutationObserver;
function MutationRecord(type, record = {}) {
return {type, ...record};
function mutationRecord(type, record = {}) {
return { type, ...record };
}

@@ -1,3 +0,1 @@

"use strict";
const userAgentSymbol = Symbol.for("userAgent");

@@ -14,3 +12,3 @@ const geolocationSymbol = Symbol.for("geolocation");

class Navigator {
export default class Navigator {
constructor(userAgent) {

@@ -33,3 +31,1 @@ this[userAgentSymbol] = userAgent || "Tallahassee";

}
module.exports = Navigator;

@@ -1,7 +0,6 @@

"use strict";
import DOMException from "domexception";
const DOMException = require("domexception");
const nodeTypes = require("./nodeTypes");
const NodeList = require("./NodeList");
const EventTarget = require("./EventTarget");
import * as nodeTypes from "./nodeTypes.js";
import NodeList from "./NodeList.js";
import EventTarget from "./EventTarget.js";

@@ -11,3 +10,3 @@ const kDocument = Symbol.for("document");

class Node extends EventTarget {
export default class Node extends EventTarget {
constructor(document, $elm) {

@@ -21,3 +20,5 @@ super();

}
get baseURI() {}
get baseURI() {
return this[kDocument].defaultView.location.href;
}
get childNodes() {

@@ -153,3 +154,1 @@ return new NodeList(this);

}
module.exports = Node;

@@ -1,5 +0,3 @@

"use strict";
import MutationObserver from "./MutationObserver.js";
const MutationObserver = require("./MutationObserver");
const kElement = Symbol.for("element");

@@ -44,3 +42,3 @@ const kSelector = Symbol.for("selector");

module.exports = class NodeList {
export default class NodeList {
constructor(parentElement, selector, options = { attributes: true }) {

@@ -53,3 +51,3 @@ const liveList = this[kLiveList] = [];

const observer = new MutationObserver(this._updateList.bind(this));
observer.observe(parentElement, {childList: true, attributes: true});
observer.observe(parentElement, { childList: true, attributes: true });
}

@@ -62,3 +60,3 @@ this._updateList();

return this[kLiveList].length;
}
},
});

@@ -100,2 +98,2 @@

}
};
}

@@ -1,13 +0,9 @@

"use strict";
module.exports = {
ELEMENT_NODE: 1, // An Element node like <p> or <div>.
ATTRIBUTE_NODE: 2, // An Attribute of an Element.
TEXT_NODE: 3, // The actual Text inside an Element or Attr.
CDATA_SECTION_NODE: 4, // A CDATASection, such as <!CDATA[[ … ]]>.
PROCESSING_INSTRUCTION_NODE: 7, // A ProcessingInstruction of an XML document, such as <?xml-stylesheet … ?>.
COMMENT_NODE: 8, // A Comment node, such as <!-- … -->.
DOCUMENT_NODE: 9, // A Document node.
DOCUMENT_TYPE_NODE: 10, // A DocumentType node, such as <!DOCTYPE html>.
DOCUMENT_FRAGMENT_NODE: 11, // A DocumentFragment node.
};
export const ELEMENT_NODE = 1; // An Element node like <p> or <div>.
export const ATTRIBUTE_NODE = 2; // An Attribute of an Element.
export const TEXT_NODE = 3; // The actual Text inside an Element or Attr.
export const CDATA_SECTION_NODE = 4; // A CDATASection, such as <!CDATA[[ … ]]>.
export const PROCESSING_INSTRUCTION_NODE = 7; // A ProcessingInstruction of an XML document, such as <?xml-stylesheet … ?>.
export const COMMENT_NODE = 8; // A Comment node, such as <!-- … -->.
export const DOCUMENT_NODE = 9; // A Document node.
export const DOCUMENT_TYPE_NODE = 10; // A DocumentType node, such as <!DOCTYPE html>.
export const DOCUMENT_FRAGMENT_NODE = 11; // A DocumentFragment node.

@@ -1,6 +0,4 @@

"use strict";
import http from "http";
const http = require("http");
module.exports = class Origin {
export default class Origin {
constructor(origin) {

@@ -48,2 +46,2 @@ this.origin = origin;

}
};
}

@@ -1,6 +0,4 @@

"use strict";
import NodeList from "./NodeList.js";
const NodeList = require("./NodeList");
module.exports = class RadioNodeList extends NodeList {
export default class RadioNodeList extends NodeList {
constructor(parentElement, name) {

@@ -18,2 +16,2 @@ const selector = `input[type=radio][name="${name}"]`;

}
};
}

@@ -1,16 +0,10 @@

"use strict";
const emptyString = "";
module.exports = Storage;
export default function Storage() {
const oStorage = { length: 0 };
function Storage() {
const oStorage = {
length: 0
};
Object.defineProperty(oStorage, "getItem", {
value(key) {
return this.hasOwnProperty(key) ? this[key] : null;
}
return Object.hasOwnProperty.call(this, key) ? this[key] : null;
},
});

@@ -22,3 +16,3 @@

this[key] = emptyString + value;
}
},
});

@@ -29,3 +23,3 @@

return Object.keys(this).length - 1;
}
},
});

@@ -37,3 +31,3 @@

delete this[key];
}
},
});

@@ -44,3 +38,3 @@

return Object.keys(oStorage).filter((p) => p !== "length")[index] || null;
}
},
});

@@ -51,6 +45,6 @@

for (const key in this) {
if (this.hasOwnProperty(key)) delete this[key];
if (Object.hasOwnProperty.call(this, key)) delete this[key];
}
this.length = 0;
}
},
});

@@ -57,0 +51,0 @@

@@ -1,6 +0,4 @@

"use strict";
import Node from "./Node.js";
const Node = require("./Node");
module.exports = class Text extends Node {
export default class Text extends Node {
get textContent() {

@@ -10,3 +8,4 @@ return this.$elm[0].data;

set textContent(value) {
return this.$elm[0].data = value;
this.$elm[0].data = value;
return value;
}

@@ -17,4 +16,5 @@ get nodeValue() {

set nodeValue(value) {
return this.$elm[0].data = value;
this.$elm[0].data = value;
return value;
}
};
}

@@ -1,3 +0,1 @@

"use strict";
const kParent = Symbol.for("parent");

@@ -169,3 +167,2 @@ const emailPattern = /^([^@\s])+@([^@\s])+$/;

class StepMismatch extends ValidateInput {

@@ -191,3 +188,3 @@ validate() {

module.exports = class ValidityState {
export default class ValidityState {
constructor(element) {

@@ -241,3 +238,2 @@ this[kParent] = element;

}
};
}

@@ -1,11 +0,9 @@

"use strict";
import { CookieAccessInfo, Cookie } from "cookiejar";
import assert from "assert";
import fetch from "node-fetch";
import { readFileSync } from "fs";
const {CookieAccessInfo, Cookie} = require("cookiejar");
const {normalizeHeaders, getLocationHost} = require("./getHeaders");
const {version} = require("../package.json");
const assert = require("assert");
const BrowserTab = require("./BrowserTab");
const NodeFetch = require("node-fetch");
const Origin = require("./Origin");
const url = require("url");
import { normalizeHeaders, getLocationHost } from "./getHeaders.js";
import BrowserTab from "./BrowserTab.js";
import Origin from "./Origin.js";

@@ -15,3 +13,5 @@ const kOrigin = Symbol.for("origin");

module.exports = class WebPage {
const { version } = JSON.parse(readFileSync("package.json"));
export default class WebPage {
constructor(origin, jar, originRequestHeaders, options) {

@@ -33,4 +33,4 @@ this[kOrigin] = origin;

const publicHost = getLocationHost(requestHeaders);
const parsedUri = url.parse(uri);
const cookieDomain = parsedUri.hostname || publicHost || this.originHost || "127.0.0.1";
const parsedUri = new URL(uri, `${this.protocol}//${publicHost || this.originHost || "127.0.0.1"}`);
const cookieDomain = parsedUri.hostname;
const isSecure = (parsedUri.protocol || this.protocol) === "https:";

@@ -99,3 +99,3 @@

}
const redirectOptions = {...requestOptions};
const redirectOptions = { ...requestOptions };

@@ -126,8 +126,8 @@ if (res.status === 307 || res.status === 308) {

return target[prop];
}
},
});
}
async makeRequest(uri, requestOptions = {method: "GET", headers: {}}) {
async makeRequest(uri, requestOptions = { method: "GET", headers: {} }) {
let origin, flOrigin;
const parsedUri = url.parse(uri);
const parsedUri = new URL(uri, `${this.protocol}//${this.originHost || "127.0.0.1"}`);
let headers = requestOptions.headers = normalizeHeaders(requestOptions.headers);

@@ -138,3 +138,3 @@ const isLocal = this.isOriginUrl(uri);

flOrigin = await origin.init();
uri = new URL(parsedUri.path, flOrigin).toString();
uri = new URL(`${parsedUri.pathname}${parsedUri.search}`, flOrigin).toString();
headers = requestOptions.headers = {

@@ -151,3 +151,3 @@ ...this.originRequestHeaders,

const isSecure = (parsedUri.protocol || this.protocol) === "https:";
const accessInfo = CookieAccessInfo(cookieDomain, parsedUri.pathname, isSecure);
const accessInfo = new CookieAccessInfo(cookieDomain, parsedUri.pathname, isSecure);

@@ -158,3 +158,3 @@ const cookieValue = this.jar.getCookies(accessInfo).toValueString();

try {
const response = await NodeFetch(uri, {...requestOptions, redirect: "manual"});
const response = await fetch(uri, { ...requestOptions, redirect: "manual" });
if (isLocal) {

@@ -185,2 +185,2 @@ response.headers.set("fl-origin", flOrigin);

}
};
}

@@ -1,21 +0,19 @@

"use strict";
import { EventEmitter } from "events";
import { performance } from "perf_hooks";
const {atob, btoa} = require("./atobtoa");
const {Event, CustomEvent, KeyboardEvent} = require("./Events");
const {EventEmitter} = require("events");
const {performance} = require("perf_hooks");
const CustomElementRegistry = require("./CustomElementRegistry");
const Element = require("./Element");
const HTMLElement = require("./HTMLElement");
const FormData = require("./FormData");
const History = require("./History");
const Location = require("./Location");
const MediaQueryList = require("./MediaQueryList");
const MutationObserver = require("./MutationObserver");
const Navigator = require("./Navigator");
const Node = require("./Node");
const url = require("url");
const XMLHttpRequest = require("./XMLHttpRequest");
const HTMLImageElement = require("./HTMLImageElement");
const HTMLIFrameElement = require("./HTMLIFrameElement");
import { atob, btoa } from "./atobtoa.js";
import { Event, CustomEvent, KeyboardEvent } from "./Events.js";
import CustomElementRegistry from "./CustomElementRegistry.js";
import Element from "./Element.js";
import HTMLElement from "./HTMLElement.js";
import FormData from "./FormData.js";
import History from "./History.js";
import Location from "./Location.js";
import MediaQueryList from "./MediaQueryList.js";
import MutationObserver from "./MutationObserver.js";
import Navigator from "./Navigator.js";
import Node from "./Node.js";
import XMLHttpRequest from "./XMLHttpRequest.js";
import HTMLImageElement from "./HTMLImageElement.js";
import HTMLIFrameElement from "./HTMLIFrameElement.js";

@@ -34,8 +32,8 @@ const kResponse = Symbol.for("response");

module.exports = class Window {
constructor(resp, windowObjects = {console}, userAgent, options) {
export default class Window {
constructor(resp, windowObjects = { console }, userAgent, options) {
this[kResponse] = resp;
this[kOptions] = options;
const webPageUrl = windowObjects.location ? url.format(windowObjects.location) : resp.url;
const webPageUrl = windowObjects.location ? windowObjects.location : resp.url;
const location = this[locationSymbol] = new Location(this, webPageUrl);

@@ -46,3 +44,3 @@

this[windowSizeSymbol] = {innerWidth: 760, innerHeight: 760};
this[windowSizeSymbol] = { innerWidth: 760, innerHeight: 760 };
this[emitterSymbol] = new EventEmitter();

@@ -61,3 +59,3 @@ this[pageOffsetSymbol] = {

// eslint-disable-next-line no-unused-vars
const {location: initLocation, ...overrides} = windowObjects;
const { location: initLocation, ...overrides } = windowObjects;
Object.assign(this, overrides);

@@ -90,3 +88,4 @@ }

set innerHeight(value) {
return this[windowSizeSymbol].innerHeight = value;
this[windowSizeSymbol].innerHeight = value;
return value;
}

@@ -97,3 +96,4 @@ get innerWidth() {

set innerWidth(value) {
return this[windowSizeSymbol].innerWidth = value;
this[windowSizeSymbol].innerWidth = value;
return value;
}

@@ -121,3 +121,3 @@ get navigator() {

enumerable: false,
writable: false
writable: false,
});

@@ -174,3 +174,3 @@ return Image;

if (xCoord && typeof xCoord === "object") {
const {top, left} = xCoord;
const { top, left } = xCoord;
pageOffset.Y = !isNaN(top) ? top : pageOffset.Y;

@@ -214,2 +214,2 @@ pageOffset.X = !isNaN(left) ? left : pageOffset.X;

}
};
}

@@ -1,9 +0,7 @@

"use strict";
import http from "http";
import https from "https";
const { Event } = require("./Events");
const { parse } = require("url");
const http = require("http");
const https = require("https");
const EventTarget = require("./EventTarget");
const Origin = require("./Origin");
import { Event } from "./Events.js";
import EventTarget from "./EventTarget.js";
import Origin from "./Origin.js";

@@ -53,2 +51,4 @@ const kData = Symbol.for("response text");

return `${readyState} DONE`;
default:
return "";
}

@@ -83,4 +83,4 @@ }

const window = this[kWindow];
const parsedUri = parse(url);
const isLocal = url.startsWith("/") || parsedUri.hostname === window.location.hostname;
const parsedUri = new URL(url, `${window.location.protocol}//${window.location.hostname}`);
const isLocal = parsedUri.hostname === window.location.hostname;
const result = { url, headers: {} };

@@ -103,3 +103,3 @@

const base = origin.initSync();
const originUrl = new URL(parsedUri.path, base);
const originUrl = new URL(parsedUri.pathname, base);

@@ -114,3 +114,3 @@ result.url = originUrl.toString();

}
_makeRequest(method, {url, headers, origin}) {
_makeRequest(method, { url, headers, origin }) {
const uri = new URL(url);

@@ -124,3 +124,3 @@ const req = this[kRequest] = (uri.protocol === "https:" ? https : http).request({

for (const [name, value] of Object.entries(headers)) {
for (const [ name, value ] of Object.entries(headers)) {
if (value !== undefined) req.setHeader(name, value);

@@ -168,2 +168,2 @@ }

module.exports = XMLHttpRequest;
export default XMLHttpRequest;
{
"name": "@expressen/tallahassee",
"version": "14.8.0",
"version": "14.9.0",
"description": "Lightweight client testing framework",
"type": "module",
"main": "index.js",

@@ -10,3 +11,3 @@ "license": "BSD-3-Clause",

"posttest": "eslint . --cache && npm run test-md && npm run toc",
"test-md": "NODE_OPTIONS=\"--experimental-vm-modules --no-warnings\" node ./scripts/test-md ./README.md,./docs/API.md,./docs/Examples.md",
"test-md": "NODE_OPTIONS=\"--experimental-vm-modules --no-warnings\" node ./scripts/test-md.js ./README.md,./docs/API.md,./docs/Examples.md",
"toc": "node ./scripts/generate-api-toc ./docs/API.md,./docs/Examples.md"

@@ -35,3 +36,3 @@ },

"domexception": "^4.0.0",
"node-fetch": "^2.6.7"
"node-fetch": "^2.6.9"
},

@@ -42,2 +43,3 @@ "devDependencies": {

"eslint": "^8.28.0",
"eslint-config-exp": "^0.5.0",
"express": "^4.18.2",

@@ -44,0 +46,0 @@ "markdown-toc": "^1.2.0",

@@ -21,12 +21,10 @@ Tallahassee

```javascript
"use strict";
import Browser from "@expressen/tallahassee";
import Script from "@bonniernews/wichita";
import {app} from "../../app/app.js";
const app = require("../app/app");
const Browser = require("@expressen/tallahassee");
const Script = require("@bonniernews/wichita");
describe("Tallahassee", () => {
describe("navigateTo()", () => {
it("navigates to url", async () => {
await Browser(app).navigateTo("/");
await new Browser(app).navigateTo("/");
});

@@ -36,3 +34,3 @@

try {
await Browser(app).navigateTo("/404");
await new Browser(app).navigateTo("/404");
} catch (e) {

@@ -45,3 +43,3 @@ var err = e; // eslint-disable-line no-var

it("unless you override status code", async () => {
const browser = await Browser(app).navigateTo("/404", null, 404);
const browser = await new Browser(app).navigateTo("/404", null, 404);
expect(browser.document.getElementsByTagName("h1")[0].innerText).to.equal("Apocalyptic");

@@ -53,3 +51,3 @@ });

it("run es6 script sources with @bonniernews/wichita", async () => {
const browser = await Browser(app).navigateTo("/", {
const browser = await new Browser(app).navigateTo("/", {
Cookie: "_ga=1"

@@ -65,3 +63,3 @@ });

it("again", async () => {
const browser = await Browser(app).navigateTo("/");
const browser = await new Browser(app).navigateTo("/");

@@ -68,0 +66,0 @@ await Script("./app/assets/scripts/main.js").run(browser.window);

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc