![Oracle Drags Its Feet in the JavaScript Trademark Dispute](https://cdn.sanity.io/images/cgdhsj6q/production/919c3b22c24f93884c548d60cbb338e819ff2435-1024x1024.webp?w=400&fit=max&auto=format)
Security News
Oracle Drags Its Feet in the JavaScript Trademark Dispute
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
jsdom-extra
Advanced tools
JSDOM with extra tweak ( jquery / cheerio / request )
npm i jsdom-extra
if u didn't need jquery or cheerio, then no need install them.
but never try set/get $ from jsdom
or will throw Error
API options for jquery / cheerio
npm i jsdom-extra jquery
npm i jsdom-extra cheerio
if virtualConsole === false
this is help if u didn't wanna see console output from jsdom
// old way
options.virtualConsole = new VirtualConsole();
// new way
options.virtualConsole = false;
// return jquery or cheerio
let $ = createJSDOM().$;
$(':root').length;
with create jsdom with extra prototype
export interface IJSDOM extends JSDOM {
$: JQueryStatic;
url: URL;
document: Document;
_options: IJSDOM_Symbol_Options;
fakeThen<T>(cb: (jsdom: IJSDOM) => T): T;
}
export declare function createJSDOM(html?: string | Buffer | BinaryData, options?: IConstructorOptions): IJSDOM;
// fake .then, not realy Promise, still is sync
createJSDOM().fakeThen(function (jsdom)
{
console.log(jsdom._options);
});
asyncJSDOM().then(function (jsdom)
{
console.log(jsdom._options);
});
pack any jsdom object with extra
import { JSDOM } from 'jsdom';
import { packJSDOM } from 'jsdom-extra';
let jsdom2 = new JSDOM();
// will overwrite jsdom2 too
packJSDOM(jsdom2) // => return jsdom2
allow use POST on fromURL
function fromURL(url: string, options?: IFromUrlOptions): Promise<IJSDOM>
export interface IFromUrlOptions extends Partial<FromUrlOptions & IOptionsJSDOM>
{
requestOptions?: Partial<IRequestOptions>,
cookieJar?: ICookieJar,
}
export interface IRequestOptionsJSDOM
{
resolveWithFullResponse: boolean;
encoding: null;
gzip: boolean;
headers: {
"User-Agent": string;
Referer: string;
Accept: string;
"Accept-Language": string;
};
jar: IRequestJar;
}
export interface IRequestOptions extends Partial<IRequestOptionsJSDOM>
{
method?: 'POST' | 'GET' | string,
form?: {
[key: string]: any,
[key: number]: any,
},
}
function fromFile(url: string, options?: IFromFileOptions): Promise<IJSDOM>
createJSDOM()._options.ConstructorOptions
output
{ windowOptions:
{ url: 'about:blank',
referrer: '',
contentType: 'text/html',
parsingMode: 'html',
userAgent: 'Mozilla/5.0 (win32) AppleWebKit/537.36 (KHTML, like Gecko) jsdom/11.6.2',
parseOptions: [Object],
runScripts: undefined,
encoding: 'UTF-8',
pretendToBeVisual: false,
virtualConsole: [VirtualConsole],
cookieJar: [CookieJar] },
resources: undefined,
beforeParse: [Function] }
will overwrite global JSDOM
import JSDOM from 'jsdom-extra/auto';
const JSDOM = require("jsdom-extra/auto").JSDOM;
same as jsdom-global
, but with
function globalJsdom<T>(html?, options: Partial<T & IConstructorOptions & IOptions> = {})
require("jsdom-extra/global")()
const globalJsdom = require("jsdom-extra/global");
globalJsdom();
let ret: {
jsdom: IGlobalJSDOM;
window: DOMWindow;
document: Document;
cleanup: () => void;
};
ret = globalJsdom();
ret.cleanup();
ret.jsdom.cleanup();
Simple: Use Mocha's --require
option. Add this to the test/mocha.opts
file (create it if it doesn't exist)
mocha --require jsdom-extra/lib/global/register
Advanced: For finer control, you can instead add it via mocha's before
and after
hooks.
before(function () {
this.globalJsdom = require('jsdom-extra/global')()
})
after(function () {
this.globalJsdom.cleanup()
})
FAQs
JSDOM with extra tweak ( jquery / cheerio / request )
The npm package jsdom-extra receives a total of 0 weekly downloads. As such, jsdom-extra popularity was classified as not popular.
We found that jsdom-extra demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
Security News
The Linux Foundation is warning open source developers that compliance with global sanctions is mandatory, highlighting legal risks and restrictions on contributions.
Security News
Maven Central now validates Sigstore signatures, making it easier for developers to verify the provenance of Java packages.