Skip to content

Commit

Permalink
Better scope fallback for Node/global/window
Browse files Browse the repository at this point in the history
Manually implemented a better fallback from PR #134
This is intended to help with running in non-browser environments like Node and Vite.
Bumped dev-time packages.
Also moved the ensureSandboxWindow method out one layer in preparation for upcoming PR #135 for pruning.
  • Loading branch information
IDisposable committed Apr 26, 2023
1 parent 2562a0a commit 12003de
Show file tree
Hide file tree
Showing 6 changed files with 131 additions and 133 deletions.
20 changes: 10 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@

The 3.x release branch included some breaking changes in the vary infrequently used ability to configure some utility methods used in this internal processing of dom-to-image-more. As browsers have matured, many of the hacks we're accumulated over the years are not needed, or better ways have been found to handle some edge-cases. With the help of folks like @meche-gh, in #99 we're stripping out the following members:

- `.mimes` - was the not-very-comprehensive list of mime types used to handle inlining things
- `.parseExtension` - was a method to extract the extension from a filename, used to guess mime types
- `.mimeType` - was a method to map file extensions to mime types
- `.dataAsUrl` - was a method to reassemble a `data:` URI from a Base64 representation and mime type
- `.mimes` - was the not-very-comprehensive list of mime types used to handle inlining things
- `.parseExtension` - was a method to extract the extension from a filename, used to guess mime types
- `.mimeType` - was a method to map file extensions to mime types
- `.dataAsUrl` - was a method to reassemble a `data:` URI from a Base64 representation and mime type

The 3.x release branch should also fix more node compatibility and `iframe` issues.

Expand Down Expand Up @@ -207,16 +207,16 @@ _Safari [is not supported](https://github.com/tsayen/dom-to-image/issues/27), as

Only standard lib is currently used, but make sure your browser supports:

- [Promise](https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Global_Objects/Promise)
- SVG `<foreignObject>` tag
- [Promise](https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Global_Objects/Promise)
- SVG `<foreignObject>` tag

### Tests

As of this v3 branch chain, the testing jig is taking advantage of the `onclone` hook to insert the clone-output into the testing page. This should make it a tiny bit easier to track down where exactly the inlining of CSS styles against the DOM nodes is wrong.

Most importantly, tests **only** depend on:

- [ocrad.js](https://github.com/antimatter15/ocrad.js), for the
- [ocrad.js](https://github.com/antimatter15/ocrad.js), for the
parts when you can't compare images (due to the browser
rendering differences) and just have to test whether the text is rendered

Expand Down Expand Up @@ -284,16 +284,16 @@ for you, following steps are taken:

## Things to watch out for

- if the DOM node you want to render includes a `<canvas>` element with something drawn on it, it should be handled fine, unless the canvas is [tainted](https://developer.mozilla.org/en-US/docs/Web/HTML/CORS_enabled_image) - in this case rendering will rather not succeed.
- if the DOM node you want to render includes a `<canvas>` element with something drawn on it, it should be handled fine, unless the canvas is [tainted](https://developer.mozilla.org/en-US/docs/Web/HTML/CORS_enabled_image) - in this case rendering will rather not succeed.

- at the time of writing, Firefox has a problem with some external stylesheets (see issue #13). In such case, the error will be caught and logged.
- at the time of writing, Firefox has a problem with some external stylesheets (see issue #13). In such case, the error will be caught and logged.

## Authors

Marc Brooks, Anatolii Saienko (original dom-to-image), Paul Bakaus (original idea),
Aidas Klimas (fixes), Edgardo Di Gesto (fixes), 樊冬 Fan Dong (fixes), Shrijan Tripathi (docs),
SNDST00M (optimize), Joseph White (performance CSS), Phani Rithvij (test),
David DOLCIMASCOLO (packaging), Zee (ZM) @zm-cttae (many major updates), Joshua Walsh @JoshuaWalsh (Firefox issues), Emre Coban @emrecoban (documentation)
David DOLCIMASCOLO (packaging), Zee (ZM) @zm-cttae (many major updates), Joshua Walsh @JoshuaWalsh (Firefox issues), Emre Coban @emrecoban (documentation), Nate Stuyvesant @nstuyvesant (fixes)


## License
Expand Down
4 changes: 2 additions & 2 deletions dist/dom-to-image-more.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/dom-to-image-more.min.js.map

Large diffs are not rendered by default.

68 changes: 34 additions & 34 deletions package-lock.json

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

15 changes: 8 additions & 7 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,27 +1,27 @@
{
"name": "dom-to-image-more",
"version": "3.1.4",
"version": "3.1.5",
"description": "Generates an image from a DOM node using HTML5 canvas and SVG",
"main": "dist/dom-to-image-more.min.js",
"devDependencies": {
"chai": "^4.3.7",
"eslint": "^8.38.0",
"eslint": "^8.39.0",
"grunt": "^1.6.1",
"grunt-cli": "^1.4.3",
"grunt-contrib-jshint": "^3.2.0",
"grunt-contrib-uglify": "^5.2.2",
"grunt-contrib-watch": "^1.1.0",
"grunt-karma": "^4.0.2",
"js-yaml": "^4.1.0",
"karma": "^6.4.1",
"karma": "^6.4.2",
"karma-chai": "^0.1.0",
"karma-chrome-launcher": "^3.1.1",
"karma-chrome-launcher": "^3.2.0",
"karma-firefox-launcher": "^2.1.2",
"karma-mocha": "^2.0.1",
"karma-mocha-reporter": "^2.2.5",
"mocha": "^10.2.0",
"prettier": "^2.8.7",
"semver": "^7.4.0"
"prettier": "^2.8.8",
"semver": "^7.5.0"
},
"scripts": {
"format": "eslint src --fix && prettier --write .",
Expand Down Expand Up @@ -60,7 +60,8 @@
"Zee @zm-cttae",
"Andoni Zubimendi @AndoniZubimendi",
"Joshua Walsh @JoshuaWalsh",
"Emre Coban @emrecoban"
"Emre Coban @emrecoban",
"Nate Stuyvesant @nstuyvesant"
],
"license": "MIT",
"bugs": {
Expand Down
Loading

0 comments on commit 12003de

Please sign in to comment.