Skip to content

Commit

Permalink
updates d3plus-common to latest
Browse files Browse the repository at this point in the history
  • Loading branch information
davelandry committed Jan 25, 2023
1 parent 34bc27d commit d16836c
Show file tree
Hide file tree
Showing 3 changed files with 221 additions and 24 deletions.
32 changes: 16 additions & 16 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 7 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "d3plus-text",
"version": "1.1.0",
"description": "A smart SVG text box with line wrapping and automatic font size scaling.",
"main": "build/d3plus-text.full.js",
"main": "es/index.js",
"jsnext:main": "es/index",
"license": "MIT",
"homepage": "https://d3plus.org",
Expand All @@ -26,7 +26,7 @@
"d3-array": "^3.2.2",
"d3-selection": "^3.0.0",
"d3-transition": "^3.0.1",
"d3plus-common": "^1.2.0"
"d3plus-common": "^1.2.4"
},
"scripts": {
"build": "d3plus-build",
Expand All @@ -37,9 +37,9 @@
"test": "eslint src test && mocha 'test/**/*-test.js'"
},
"devDependencies": {
"d3plus-dev": "^1.2.6"
"d3plus-dev": "^1.2.8"
},
"module": "es/index",
"module": "es/index.js",
"sideEffects": false,
"files": [
"bin",
Expand All @@ -48,5 +48,7 @@
"build/d3plus-text.min.js",
"es"
],
"type": "module"
"type": "module",
"jsdelivr": "build/d3plus-text.full.min.js",
"unpkg": "build/d3plus-text.full.min.js"
}
201 changes: 198 additions & 3 deletions test/jsdom.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import {JSDOM} from "jsdom";

const defaultHTML = "<!doctype html><html><head><meta charset='utf-8'></head><body></body></html>";

/**
*
* @param {String} message Test message to pass as first argument to the "it" functoin.
Expand All @@ -8,19 +10,212 @@ import {JSDOM} from "jsdom";
* @returns
*/
export default function jsdomit(message, html, run) {
if (arguments.length < 3) run = html, html = "";
if (arguments.length < 3) run = html, html = defaultHTML;
return it(message, async() => {
try {
const dom = new JSDOM(html);
global.window = dom.window;
global.document = dom.window.document;
global.DOMParser = dom.window.DOMParser;
KEYS.forEach(function (key) {
global[key] = window[key];
});
await run();
}
finally {
delete global.window;
delete global.document;
delete global.DOMParser;
KEYS.forEach(function (key) { delete global[key] });
}
});
}

// See jsdom's lib/jsdom/living/index.js
var LIVING_KEYS = [
'DOMParser',
'DOMException',
'NamedNodeMap',
'Attr',
'Node',
'Element',
'DocumentFragment',
'HTMLDocument',
'Document',
'CharacterData',
'Comment',
'DocumentType',
'DOMImplementation',
'ProcessingInstruction',
'Image',
'Text',
'Event',
'CustomEvent',
'MessageEvent',
'ErrorEvent',
'HashChangeEvent',
'PopStateEvent',
'UIEvent',
'MouseEvent',
'KeyboardEvent',
'TouchEvent',
'ProgressEvent',
'EventTarget',
'Location',
'History',
'HTMLElement',
'HTMLAnchorElement',
'HTMLAppletElement',
'HTMLAreaElement',
'HTMLAudioElement',
'HTMLBaseElement',
'HTMLBodyElement',
'HTMLBRElement',
'HTMLButtonElement',
'HTMLCanvasElement',
'HTMLDataElement',
'HTMLDataListElement',
'HTMLDialogElement',
'HTMLDirectoryElement',
'HTMLDivElement',
'HTMLDListElement',
'HTMLEmbedElement',
'HTMLFieldSetElement',
'HTMLFontElement',
'HTMLFormElement',
'HTMLFrameElement',
'HTMLFrameSetElement',
'HTMLHeadingElement',
'HTMLHeadElement',
'HTMLHRElement',
'HTMLHtmlElement',
'HTMLIFrameElement',
'HTMLImageElement',
'HTMLInputElement',
'HTMLLabelElement',
'HTMLLegendElement',
'HTMLLIElement',
'HTMLLinkElement',
'HTMLMapElement',
'HTMLMediaElement',
'HTMLMenuElement',
'HTMLMetaElement',
'HTMLMeterElement',
'HTMLModElement',
'HTMLObjectElement',
'HTMLOListElement',
'HTMLOptGroupElement',
'HTMLOptionElement',
'HTMLOutputElement',
'HTMLParagraphElement',
'HTMLParamElement',
'HTMLPreElement',
'HTMLProgressElement',
'HTMLQuoteElement',
'HTMLScriptElement',
'HTMLSelectElement',
'HTMLSourceElement',
'HTMLSpanElement',
'HTMLStyleElement',
'HTMLTableCaptionElement',
'HTMLTableCellElement',
'HTMLTableColElement',
'HTMLTableDataCellElement',
'HTMLTableElement',
'HTMLTableHeaderCellElement',
'HTMLTimeElement',
'HTMLTitleElement',
'HTMLTableRowElement',
'HTMLTableSectionElement',
'HTMLTemplateElement',
'HTMLTextAreaElement',
'HTMLTrackElement',
'HTMLUListElement',
'HTMLUnknownElement',
'HTMLVideoElement',
'StyleSheet',
'MediaList',
'CSSStyleSheet',
'CSSRule',
'CSSStyleRule',
'CSSMediaRule',
'CSSImportRule',
'CSSStyleDeclaration',
'StyleSheetList',
'XPathException',
'XPathExpression',
'XPathResult',
'XPathEvaluator',
'HTMLCollection',
'NodeFilter',
'NodeIterator',
'NodeList',
'Blob',
'File',
'FileList',
'FormData',
'XMLHttpRequest',
'XMLHttpRequestEventTarget',
'XMLHttpRequestUpload',
'DOMTokenList',
'URL'
]

var OTHER_KEYS = [
'addEventListener',
'alert',
'atob',
'blur',
'btoa',
/* 'clearInterval', */
/* 'clearTimeout', */
'close',
'confirm',
/* 'console', */
'createPopup',
'dispatchEvent',
'document',
'focus',
'frames',
'getComputedStyle',
'history',
'innerHeight',
'innerWidth',
'length',
'location',
'moveBy',
'moveTo',
'name',
'navigator',
'open',
'outerHeight',
'outerWidth',
'pageXOffset',
'pageYOffset',
'parent',
'postMessage',
'print',
'prompt',
'removeEventListener',
'resizeBy',
'resizeTo',
'screen',
'screenLeft',
'screenTop',
'screenX',
'screenY',
'scroll',
'scrollBy',
'scrollLeft',
'scrollTo',
'scrollTop',
'scrollX',
'scrollY',
'self',
/* 'setInterval', */
/* 'setTimeout', */
'stop',
/* 'toString', */
'top',
'window'
]

const KEYS = LIVING_KEYS.concat(OTHER_KEYS);

0 comments on commit d16836c

Please sign in to comment.