Compare commits

..

33 Commits

Author SHA1 Message Date
CI
d7d17adf70 chore(release): 1.0.0-rc.6 2020-08-08 10:19:43 +00:00
60f6b85083 Update release script (#2319) 2020-08-08 18:18:10 +08:00
CI
e3237dc4ce chore(release): 1.0.0-rc.6 2020-08-08 08:46:37 +00:00
659f820170 update standard-release (#2317) 2020-08-08 16:45:26 +08:00
f7b39c0914 update npm build (#2316) 2020-08-08 16:00:41 +08:00
cd77e1cea1 update dependencies (#2315) 2020-08-08 15:37:50 +08:00
f23e6f6f26 fix: image loading="lazy" fix #2312 (#2314) 2020-08-08 15:37:34 +08:00
04e145b5eb Update CI 2020-08-08 14:54:12 +08:00
003cfd9073 Update ci 2020-08-02 16:34:56 +08:00
9749bb1fb1 Update ci (#2307) 2020-08-02 16:14:29 +08:00
3c2c826ad7 Update ci (#2306) 2020-08-02 15:49:02 +08:00
e496047888 Update ci.yml 2020-08-02 14:39:09 +08:00
51de34787a ci: build docs (#2305) 2020-07-31 19:21:02 +08:00
6c86f5f653 Update ci.yml 2020-07-31 00:57:23 +08:00
8f4ec8a0c0 Update ci.yml 2020-07-31 00:18:23 +08:00
51aadbb7f1 Update ci.yml 2020-07-30 23:38:22 +08:00
8af7745e80 Update release.yml 2020-07-30 23:20:26 +08:00
610997923a Create release.yml 2020-07-30 23:11:27 +08:00
d844328e0a Update ci.yml 2020-07-29 18:52:46 +08:00
e0d536777a Update new ios simulators 2020-07-29 18:47:43 +08:00
cc19105c91 Update ci.yml 2020-07-29 18:30:41 +08:00
2d30554b2a Update ci.yml 2020-07-29 18:17:46 +08:00
401df79087 Update ci.yml 2020-07-29 18:16:52 +08:00
7cb0019594 Update ci.yml 2020-07-28 23:59:49 +08:00
ebe9eccbd2 Update ci.yml 2020-07-28 23:48:05 +08:00
df44c86f68 Update ci.yml 2020-07-28 23:47:14 +08:00
e083e229c9 Update ci.yml 2020-07-28 23:07:29 +08:00
b308cbd998 Create ci.yml 2020-07-28 22:59:26 +08:00
4dd4a69c7a tests(reftests): Upgrade to fontawesome v5.13.0 (#2202)
* support font-family names with numbers in (e.g. Font Awesome 5)

* check for spaces in font family names first so generic font names don't get wrapped in quotes

* Update reftest to use fontawesome 5.13.0

* Add fontawesome v4 shims

* Revert "Merge remote-tracking branch 'grahamkane/master' into issue-1948-test-coverage"

This reverts commit 5211ab4065, reversing
changes made to ae0bd29d37.

* Revert "Revert "Merge remote-tracking branch 'grahamkane/master' into issue-1948-test-coverage""

This reverts commit 4911fe25f4.

* Revert "Merge remote-tracking branch 'grahamkane/master' into issue-1948-test-coverage"

This reverts commit 5211ab4065, reversing
changes made to ae0bd29d37.

Co-authored-by: Graham Kane <grahamkane@gmail.com>
2020-04-19 16:46:25 +08:00
c366e8790d ci: Azure Pipelines: upgrade from macOS 10.13 -> 10.14 (#2204) 2020-04-15 13:03:04 +08:00
ae5f866b37 Migrate base Chrome profiles to ChromeHeadless (#2203) 2020-04-14 18:15:13 +08:00
f139b513c5 fix: #1868 Clone node, Setting className for SVG element raises error (#2079)
* fix: #1868 Clone node, Setting className for SVG element raises error

* fix: svg element type information
2019-11-25 20:55:28 -08:00
e4d52a1ac6 Fix error in server-side rendering (#2039) 2019-11-25 20:16:07 -08:00
17 changed files with 4378 additions and 1830 deletions

View File

@ -11,7 +11,7 @@ insert_final_newline = true
indent_style = space indent_style = space
indent_size = 4 indent_size = 4
[{azure-pipelines.yml,package.json, ci/*.yml}] [{*.yml,package.json}]
# The indent size used in the `package.json` file cannot be changed # The indent size used in the `package.json` file cannot be changed
# https://github.com/npm/npm/pull/3180#issuecomment-16336516 # https://github.com/npm/npm/pull/3180#issuecomment-16336516
indent_size = 2 indent_size = 2

306
.github/workflows/ci.yml vendored Normal file
View File

@ -0,0 +1,306 @@
name: CI
on:
push:
branches: [ master ]
tags:
- 'v*'
pull_request:
branches: [ master ]
jobs:
build:
runs-on: ubuntu-latest
name: Build
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v1
with:
node-version: 12
- name: Cache node modules
uses: actions/cache@v2
env:
cache-name: cache-node-modules
with:
# npm cache files are stored in `~/.npm` on Linux/macOS
path: ~/.npm
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-build-${{ env.cache-name }}-
${{ runner.os }}-build-
${{ runner.os }}-
- name: Npm install
run: npm ci
- name: Build
run: npm run build
- name: Pack
run: |
npm pack
mv html2canvas-*.tgz html2canvas.tgz
tar --list --verbose --file=html2canvas.tgz
- name: Upload npm pack
uses: actions/upload-artifact@v2
with:
name: npm
path: html2canvas.tgz
- name: Upload dist
uses: actions/upload-artifact@v2
with:
name: dist
path: dist
- name: Upload build
uses: actions/upload-artifact@v2
with:
name: build
path: build
test:
runs-on: ubuntu-latest
name: Test
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v1
with:
node-version: 12
- name: Cache node modules
uses: actions/cache@v2
env:
cache-name: cache-node-modules
with:
# npm cache files are stored in `~/.npm` on Linux/macOS
path: ~/.npm
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-build-${{ env.cache-name }}-
${{ runner.os }}-build-
${{ runner.os }}-
- name: Npm install
run: npm ci
- name: Build
run: npm run build
- name: Lint
run: npm run lint
- name: Unit tests
run: npm run unittest
browser-test:
strategy:
fail-fast: false
matrix:
config:
- os: ubuntu-latest
name: Linux Firefox Stable
targetBrowser: Firefox_Stable
xvfb: true
- os: ubuntu-latest
name: Linux Chrome Stable
targetBrowser: Chrome_Stable
xvfb: true
- os: macos-latest
name: OSX Safari Stable
targetBrowser: Safari_Stable
- os: macos-latest
name: iOS Simulator Safari 12
targetBrowser: Safari_IOS_12
xcode: /Applications/Xcode_10.3.app
- os: macos-latest
name: iOS Simulator Safari 13
targetBrowser: Safari_IOS_13
xcode: /Applications/Xcode_11.6_beta.app
- os: macos-latest
name: iOS Simulator Safari 14
targetBrowser: Safari_IOS_14
xcode: /Applications/Xcode_12_beta.app
- os: windows-latest
name: Windows Internet Explorer 9 (Emulated)
targetBrowser: IE_9
- os: windows-latest
name: Windows Internet Explorer 10 (Emulated)
targetBrowser: IE_10
- os: windows-latest
name: Windows Internet Explorer 11
targetBrowser: IE_11
runs-on: ${{ matrix.config.os }}
name: ${{ matrix.config.name }}
env:
TARGET_BROWSER: ${{ matrix.config.targetBrowser }}
needs: build
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v1
with:
node-version: 12
- name: Cache node modules
uses: actions/cache@v2
env:
cache-name: cache-node-modules
with:
# npm cache files are stored in `~/.npm` on Linux/macOS
path: ~/.npm
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-build-${{ env.cache-name }}-
${{ runner.os }}-build-
${{ runner.os }}-
- name: Npm install
run: npm ci
- name: Download library
uses: actions/download-artifact@v2
with:
name: dist
path: dist
- name: Download test-runner
uses: actions/download-artifact@v2
with:
name: build
path: build
- name: xcode selection
if: ${{ matrix.config.xcode != '' }}
run: sudo xcode-select -s "${{ matrix.config.xcode }}"
- name: Run browser tests
if: ${{ matrix.config.xvfb != true }}
run: npm run karma
- name: Start Xvfb
if: ${{ matrix.config.xvfb == true }}
run: Xvfb :99 &
- name: Run browser tests
if: ${{ matrix.config.xvfb == true }}
run: DISPLAY=:99 npm run karma
- name: Upload screenshots
uses: actions/upload-artifact@v2
with:
name: reftest-results
path: tmp/reftests
publish:
runs-on: ubuntu-latest
name: Publish
if: startsWith(github.ref, 'refs/tags/v')
needs: browser-test
steps:
- uses: actions/checkout@v2
- name: Download NPM package
uses: actions/download-artifact@v2
with:
name: npm
path: npm
- name: Download library
uses: actions/download-artifact@v2
with:
name: dist
path: dist
- name: Create Github Release
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ github.ref }}
release_name: ${{ github.ref }}
draft: false
prerelease: ${{ contains(github.ref, '-rc.') || contains(github.ref, '-alpha.') }}
- name: Upload html2canvas.js
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ./dist/html2canvas.js
asset_name: html2canvas.js
asset_content_type: text/javascript
- name: Upload html2canvas.min.js
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ./dist/html2canvas.min.js
asset_name: html2canvas.min.js
asset_content_type: text/javascript
- name: Upload html2canvas.esm.js
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ./dist/html2canvas.esm.js
asset_name: html2canvas.esm.js
asset_content_type: text/javascript
- name: Unpack npm
run: cd npm && tar -xvzf "html2canvas.tgz"
- uses: actions/setup-node@v1
with:
node-version: 12
registry-url: 'https://registry.npmjs.org'
- name: NPM Publish
run: cd npm/package && npm publish
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
docs:
runs-on: ubuntu-latest
name: Build docs
needs: browser-test
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v1
with:
node-version: 12
- name: Cache node modules
uses: actions/cache@v2
env:
cache-name: cache-node-modules
with:
# npm cache files are stored in `~/.npm` on Linux/macOS
path: ~/.npm
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-build-${{ env.cache-name }}-
${{ runner.os }}-build-
${{ runner.os }}-
- name: Npm install
run: npm ci
- name: Download library
uses: actions/download-artifact@v2
with:
name: dist
path: www/static/dist
- name: Download test results
uses: actions/download-artifact@v2
with:
name: reftest-results
path: www/static/results
- name: Copy reftests to docs website
run: cp -R tests/reftests www/static/tests/reftests && cp -R tests/assets www/static/tests/assets && cp tests/test.js www/static/tests/test.js
- name: Create reftest result index
run: npm run build:reftest-result-list www/static/results/metadata www/src/results.json
- name: Create reftest previewer
run: npm run build:reftest-preview
- name: Clean metadata folder
run: rm -rf www/static/results/metadata
- name: Build docs
run: npm run build && cd www && npm install && npm run build && cd ..
- name: Upload docs
uses: actions/upload-artifact@v2
with:
name: docs
path: www/public
publish-docs:
runs-on: ubuntu-latest
name: Publish Docs
if: ${{ github.ref == 'refs/heads/master' || startsWith(github.ref, 'refs/tags/v') }}
needs: docs
steps:
- uses: actions/checkout@v2
with:
persist-credentials: false
- name: Download docs
uses: actions/download-artifact@v2
with:
name: docs
path: docs
- name: Publish docs
uses: JamesIves/github-pages-deploy-action@3.5.9
with:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
BRANCH: gh-pages
FOLDER: docs
SINGLE_COMMIT: true
CLEAN: true

37
.github/workflows/release.yml vendored Normal file
View File

@ -0,0 +1,37 @@
name: Create Release
on:
workflow_dispatch:
inputs:
version:
description: 'Semantic version (major | minor | patch | premajor | preminor | prepatch | prerelease)'
default: 'patch'
required: true
jobs:
version:
name: Create version
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
with:
fetch-depth: 0
token: ${{ secrets.PAT_TOKEN }}
- uses: actions/setup-node@v1
with:
node-version: 12
- name: Npm install
run: npm ci
- name: Configure git
run: |
git config user.name "CI"
git config user.email "niklasvh@gmail.com"
- name: Create release
run: npm run release -- --preset eslint --release-as ${{ github.event.inputs.version }}
- name: Print details
run: |
cat package.json
cat CHANGELOG.md
git tag
- name: Push git version
run: git push --follow-tags origin master

View File

@ -1,4 +1,8 @@
.github/
.idea/
.rpt2_cache
build/ build/
configs/
docs/ docs/
examples/ examples/
scripts/ scripts/
@ -6,17 +10,13 @@ src/
tests/ tests/
www/ www/
tmp/ tmp/
.github/
*.iml *.iml
.babelrc .babelrc
.idea/
.editorconfig .editorconfig
.npmignore
.eslintrc .eslintrc
.travis.yml .npmignore
azure-pipelines.yml .prettierrc
karma.js jest.config.js
karma.conf.js karma.conf.js
rollup.config.js karma.js
webpack.config.js rollup.config.ts
.rpt2_cache

View File

@ -1,7 +1,22 @@
# Change Log # Changelog
All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines. All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
# [1.0.0-rc.6](https://github.com/niklasvh/html2canvas/compare/v1.0.0-rc.5...v1.0.0-rc.6) (2020-08-08)
### ci
* Azure Pipelines: upgrade from macOS 10.13 -> 10.14 (#2204) ([c366e87](https://github.com/niklasvh/html2canvas/commit/c366e8790d346ea981b24b7425aef6bf6d7ebcec)), closes [#2204](https://github.com/niklasvh/html2canvas/issues/2204)
* build docs (#2305) ([51de347](https://github.com/niklasvh/html2canvas/commit/51de34787ad8aba3f213800be45e878cddb064e9)), closes [#2305](https://github.com/niklasvh/html2canvas/issues/2305)
### fix
* #1868 Clone node, Setting className for SVG element raises error (#2079) ([f139b51](https://github.com/niklasvh/html2canvas/commit/f139b513c5cf9673dc727fd47124e0d779891e3a)), closes [#1868](https://github.com/niklasvh/html2canvas/issues/1868) [#2079](https://github.com/niklasvh/html2canvas/issues/2079) [#1868](https://github.com/niklasvh/html2canvas/issues/1868)
* image loading="lazy" fix #2312 (#2314) ([f23e6f6](https://github.com/niklasvh/html2canvas/commit/f23e6f6f2690dc0dbd02621c3bb81025904e6647)), closes [#2312](https://github.com/niklasvh/html2canvas/issues/2312) [#2314](https://github.com/niklasvh/html2canvas/issues/2314)
# [1.0.0-rc.5](https://github.com/niklasvh/html2canvas/compare/v1.0.0-rc.4...v1.0.0-rc.5) (2019-09-27) # [1.0.0-rc.5](https://github.com/niklasvh/html2canvas/compare/v1.0.0-rc.4...v1.0.0-rc.5) (2019-09-27)

View File

@ -4,7 +4,7 @@ html2canvas
[Homepage](https://html2canvas.hertzen.com) | [Downloads](https://github.com/niklasvh/html2canvas/releases) | [Questions](http://stackoverflow.com/questions/tagged/html2canvas?sort=newest) [Homepage](https://html2canvas.hertzen.com) | [Downloads](https://github.com/niklasvh/html2canvas/releases) | [Questions](http://stackoverflow.com/questions/tagged/html2canvas?sort=newest)
[![Gitter](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/niklasvh/html2canvas?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge) [![Gitter](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/niklasvh/html2canvas?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge)
[![Build Status](https://dev.azure.com/niklasvh/html2canvas/_apis/build/status/niklasvh.html2canvas?branchName=master)](https://dev.azure.com/niklasvh/html2canvas/_build/latest?definitionId=1&branchName=master) ![CI](https://github.com/niklasvh/html2canvas/workflows/CI/badge.svg?branch=master)
[![NPM Downloads](https://img.shields.io/npm/dm/html2canvas.svg)](https://www.npmjs.org/package/html2canvas) [![NPM Downloads](https://img.shields.io/npm/dm/html2canvas.svg)](https://www.npmjs.org/package/html2canvas)
[![NPM Version](https://img.shields.io/npm/v/html2canvas.svg)](https://www.npmjs.org/package/html2canvas) [![NPM Version](https://img.shields.io/npm/v/html2canvas.svg)](https://www.npmjs.org/package/html2canvas)

View File

@ -1,170 +0,0 @@
trigger:
- master
jobs:
- job: Build
displayName: Build
pool:
vmImage: 'Ubuntu-16.04'
steps:
- task: NodeTool@0
inputs:
versionSpec: '10.x'
displayName: 'Install Node.js'
- task: Npm@0
inputs:
command: install
- script: npm run build
displayName: Build
- script: |
npm pack
mv html2canvas-*.tgz html2canvas.tgz
tar --list --verbose --file=html2canvas.tgz
displayName: Pack
name: pack
- task: PublishBuildArtifacts@1
inputs:
PathtoPublish: html2canvas.tgz
artifactName: npm
- task: PublishBuildArtifacts@1
inputs:
PathtoPublish: 'dist'
artifactName: dist
- task: PublishBuildArtifacts@1
inputs:
PathtoPublish: 'build'
artifactName: build
- job: Test
displayName: Tests
pool:
vmImage: 'Ubuntu-16.04'
steps:
- task: NodeTool@0
inputs:
versionSpec: '10.x'
displayName: 'Install Node.js'
- task: Npm@0
inputs:
command: install
- script: npm run build
displayName: Build
- script: npm run lint
displayName: Lint
- script: npm run unittest
displayName: Unit tests
- template: ci/browser-tests.yml
parameters:
name: Browser_Tests_Linux_Firefox_Stable
displayName: Linux Firefox Stable
vmImage: 'ubuntu-16.04'
targetBrowser: Firefox_Stable
xvfb: true
- template: ci/browser-tests.yml
parameters:
name: Browser_Tests_Linux_Chrome_Stable
displayName: Linux Chrome Stable
vmImage: 'ubuntu-16.04'
targetBrowser: Chrome_Stable
xvfb: true
- template: ci/browser-tests.yml
parameters:
name: Browser_Tests_OSX_Safari_IOS_9
displayName: iOS Simulator Safari 9
vmImage: 'macOS-10.13'
targetBrowser: Safari_IOS_9
- template: ci/browser-tests.yml
parameters:
name: Browser_Tests_OSX_Safari_IOS_10
displayName: iOS Simulator Safari 10
vmImage: 'macOS-10.13'
targetBrowser: Safari_IOS_10
- template: ci/browser-tests.yml
parameters:
name: Browser_Tests_OSX_Safari_IOS_12
displayName: iOS Simulator Safari 12
vmImage: 'macOS-10.13'
targetBrowser: Safari_IOS_12
- template: ci/browser-tests.yml
parameters:
name: Browser_Tests_OSX_Safari_Stable
displayName: OSX Safari Stable
vmImage: 'macOS-10.13'
targetBrowser: Safari_Stable
- template: ci/browser-tests.yml
parameters:
name: Browser_Tests_Windows_IE9
displayName: Windows Internet Explorer 9 (Emulated)
vmImage: 'vs2017-win2016'
targetBrowser: IE_9
- template: ci/browser-tests.yml
parameters:
name: Browser_Tests_Windows_IE10
displayName: Windows Internet Explorer 10 (Emulated)
vmImage: 'vs2017-win2016'
targetBrowser: IE_10
- template: ci/browser-tests.yml
parameters:
name: Browser_Tests_Windows_IE11
displayName: Windows Internet Explorer 11
vmImage: 'vs2017-win2016'
targetBrowser: IE_11
- job: Build_docs
displayName: Build docs
pool:
vmImage: 'Ubuntu-16.04'
dependsOn:
- Browser_Tests_Linux_Firefox_Stable
- Browser_Tests_Linux_Chrome_Stable
- Browser_Tests_OSX_Safari_IOS_9
- Browser_Tests_OSX_Safari_IOS_10
- Browser_Tests_OSX_Safari_IOS_12
- Browser_Tests_OSX_Safari_Stable
- Browser_Tests_Windows_IE9
- Browser_Tests_Windows_IE10
- Browser_Tests_Windows_IE11
steps:
- task: NodeTool@0
inputs:
versionSpec: '10.x'
displayName: 'Install Node.js'
- task: Npm@0
inputs:
command: install
- task: DownloadBuildArtifacts@0
displayName: 'Download test results'
inputs:
artifactName: ReftestResults
downloadPath: $(System.DefaultWorkingDirectory)
- task: DownloadBuildArtifacts@0
displayName: 'Download dist'
inputs:
artifactName: dist
downloadPath: $(System.DefaultWorkingDirectory)
- script: cp -R tests/reftests www/static/tests/reftests && cp -R tests/assets www/static/tests/assets && cp tests/test.js www/static/tests/test.js && cp -R ReftestResults ./www/static/results
displayName: Copy reftests to docs website
- script: cp -R dist ./www/static/dist
displayName: Copy dist to docs website
- script: npm run build:reftest-result-list www/static/results/metadata www/src/results.json
displayName: Create reftest result index
- script: npm run build:reftest-preview
displayName: Create reftest previewer
- script: rm -rf www/static/results/metadata
displayName: Clean metadata folder
- script: npm run build && cd www && npm install && npm run build && cd ..
displayName: Build docs
- task: PublishBuildArtifacts@1
displayName: Upload docs website artifact
inputs:
PathtoPublish: 'www/public'
artifactName: docs

View File

@ -1,52 +0,0 @@
parameters:
name: ''
vmImage: ''
targetBrowser: ''
xvfb: false
jobs:
- job: ${{ parameters.name }}
displayName: ${{ parameters.displayName }}
pool:
vmImage: ${{ parameters.vmImage }}
variables:
TARGET_BROWSER: ${{ parameters.targetBrowser }}
dependsOn: Build
condition: succeeded()
steps:
- task: NodeTool@0
inputs:
versionSpec: '10.x'
displayName: 'Install Node.js'
- task: Npm@0
inputs:
command: install
- task: DownloadBuildArtifacts@0
displayName: 'Download library'
inputs:
artifactName: dist
downloadPath: $(System.DefaultWorkingDirectory)
- task: DownloadBuildArtifacts@0
displayName: 'Download testrunner'
inputs:
artifactName: build
downloadPath: $(System.DefaultWorkingDirectory)
- ${{ if not(eq(parameters.xvfb, 'true')) }}:
- script: npm run karma
displayName: 'Run browser tests'
- ${{ if eq(parameters.xvfb, 'true') }}:
- script: Xvfb :99 &
displayName: 'Start Xvfb'
- script: DISPLAY=:99 npm run karma
displayName: 'Run browser tests'
- task: PublishTestResults@2
condition: succeededOrFailed()
inputs:
testRunner: JUnit
testResultsFiles: 'tmp/junit/*.xml'
- task: PublishBuildArtifacts@1
displayName: Upload Screenshots
condition: succeededOrFailed()
inputs:
PathtoPublish: 'tmp/reftests'
artifactName: ReftestResults

View File

@ -4,26 +4,43 @@
const path = require('path'); const path = require('path');
const simctl = require('node-simctl'); const simctl = require('node-simctl');
const iosSimulator = require('appium-ios-simulator'); const iosSimulator = require('appium-ios-simulator');
const listenAddress = 'localhost';
const port = 9876; const port = 9876;
const log = require('karma/lib/logger').create('launcher:MobileSafari'); const log = require('karma/lib/logger').create('launcher:MobileSafari');
module.exports = function(config) { module.exports = function(config) {
// https://github.com/actions/virtual-environments/blob/master/images/macos/macos-10.15-Readme.md
const launchers = { const launchers = {
Safari_IOS_9: { Safari_IOS_9: {
base: 'MobileSafari', base: 'MobileSafari',
name: 'iPhone 5s', name: 'iPhone 5s',
platform: 'iOS',
sdk: '9.0' sdk: '9.0'
}, },
Safari_IOS_10: { Safari_IOS_10: {
base: 'MobileSafari', base: 'MobileSafari',
name: 'iPhone 5s', name: 'iPhone 5s',
platform: 'iOS',
sdk: '10.0' sdk: '10.0'
}, },
Safari_IOS_12: { Safari_IOS_12: {
base: 'MobileSafari', base: 'MobileSafari',
name: 'iPhone 5s', name: 'iPhone 5s',
sdk: '12.1' platform: 'iOS',
sdk: '12.4'
},
Safari_IOS_13: {
base: 'MobileSafari',
name: 'iPhone 8',
platform: 'iOS',
sdk: '13.6'
},
Safari_IOS_14: {
base: 'MobileSafari',
name: 'iPhone 8',
platform: 'iOS',
sdk: '14.0'
}, },
SauceLabs_IE9: { SauceLabs_IE9: {
base: 'SauceLabs', base: 'SauceLabs',
@ -85,10 +102,10 @@ module.exports = function(config) {
flags: ['-extoff'] flags: ['-extoff']
}, },
Safari_Stable: { Safari_Stable: {
base: 'Safari' base: 'SafariNative'
}, },
Chrome_Stable: { Chrome_Stable: {
base: 'Chrome' base: 'ChromeHeadless'
}, },
Firefox_Stable: { Firefox_Stable: {
base: 'Firefox' base: 'Firefox'
@ -99,7 +116,7 @@ module.exports = function(config) {
const customLaunchers = ciLauncher ? {target_browser: ciLauncher} : { const customLaunchers = ciLauncher ? {target_browser: ciLauncher} : {
stable_chrome: { stable_chrome: {
base: 'Chrome' base: 'ChromeHeadless'
}, },
stable_firefox: { stable_firefox: {
base: 'Firefox' base: 'Firefox'
@ -125,8 +142,8 @@ module.exports = function(config) {
} }
baseBrowserDecorator(this); baseBrowserDecorator(this);
this.on('start', url => { this.on('start', url => {
simctl.getDevices().then(devices => { simctl.getDevices(args.sdk, args.platform).then(devices => {
const d = devices[args.sdk].find(d => { const d = devices.find(d => {
return d.name === args.name; return d.name === args.name;
}); });
@ -208,6 +225,9 @@ module.exports = function(config) {
outputDir: 'tmp/junit/' outputDir: 'tmp/junit/'
}, },
// web server listen address,
listenAddress,
// web server port // web server port
port, port,

5521
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -6,7 +6,7 @@
"module": "dist/html2canvas.esm.js", "module": "dist/html2canvas.esm.js",
"typings": "dist/types/index.d.ts", "typings": "dist/types/index.d.ts",
"browser": "dist/html2canvas.js", "browser": "dist/html2canvas.js",
"version": "1.0.0-rc.5", "version": "1.0.0-rc.6",
"author": { "author": {
"name": "Niklas von Hertzen", "name": "Niklas von Hertzen",
"email": "niklasvh@gmail.com", "email": "niklasvh@gmail.com",
@ -39,7 +39,7 @@
"appium-ios-simulator": "^3.10.0", "appium-ios-simulator": "^3.10.0",
"babel-eslint": "^10.0.1", "babel-eslint": "^10.0.1",
"babel-loader": "^8.0.5", "babel-loader": "^8.0.5",
"babel-plugin-add-module-exports": "^1.0.0", "babel-plugin-add-module-exports": "^1.0.2",
"babel-plugin-dev-expression": "^0.2.1", "babel-plugin-dev-expression": "^0.2.1",
"base64-arraybuffer": "0.2.0", "base64-arraybuffer": "0.2.0",
"body-parser": "^1.18.3", "body-parser": "^1.18.3",
@ -55,7 +55,7 @@
"glob": "7.1.3", "glob": "7.1.3",
"html2canvas-proxy": "1.0.1", "html2canvas-proxy": "1.0.1",
"jest": "^24.9.0", "jest": "^24.9.0",
"jquery": "^3.4.0", "jquery": "^3.5.1",
"js-polyfills": "^0.1.42", "js-polyfills": "^0.1.42",
"karma": "^4.0.1", "karma": "^4.0.1",
"karma-chrome-launcher": "^2.2.0", "karma-chrome-launcher": "^2.2.0",
@ -64,10 +64,10 @@
"karma-ie-launcher": "^1.0.0", "karma-ie-launcher": "^1.0.0",
"karma-junit-reporter": "^1.2.0", "karma-junit-reporter": "^1.2.0",
"karma-mocha": "^1.3.0", "karma-mocha": "^1.3.0",
"karma-safari-launcher": "^1.0.0", "karma-safarinative-launcher": "^1.1.0",
"karma-sauce-launcher": "^2.0.2", "karma-sauce-launcher": "^2.0.2",
"mocha": "^6.1.4", "mocha": "^6.1.4",
"node-simctl": "^5.0.0", "node-simctl": "^5.3.0",
"platform": "1.3.4", "platform": "1.3.4",
"prettier": "1.17.0", "prettier": "1.17.0",
"replace-in-file": "^3.0.0", "replace-in-file": "^3.0.0",
@ -80,7 +80,7 @@
"rollup-plugin-typescript2": "^0.21.0", "rollup-plugin-typescript2": "^0.21.0",
"serve-index": "^1.9.1", "serve-index": "^1.9.1",
"slash": "1.0.0", "slash": "1.0.0",
"standard-version": "^5.0.2", "standard-version": "^8.0.2",
"ts-jest": "^24.1.0", "ts-jest": "^24.1.0",
"ts-loader": "^5.3.3", "ts-loader": "^5.3.3",
"ts-node": "^8.0.3", "ts-node": "^8.0.3",
@ -88,7 +88,7 @@
"uglify-js": "^3.5.11", "uglify-js": "^3.5.11",
"uglifyjs-webpack-plugin": "^1.1.2", "uglifyjs-webpack-plugin": "^1.1.2",
"webpack": "^4.29.6", "webpack": "^4.29.6",
"webpack-cli": "^3.3.0" "webpack-cli": "^3.3.12"
}, },
"scripts": { "scripts": {
"prebuild": "rimraf dist/ && rimraf build/ && mkdirp dist && mkdirp build", "prebuild": "rimraf dist/ && rimraf build/ && mkdirp dist && mkdirp build",

View File

@ -5,9 +5,11 @@ import {
isElementNode, isElementNode,
isHTMLElementNode, isHTMLElementNode,
isIFrameElement, isIFrameElement,
isImageElement,
isScriptElement, isScriptElement,
isSelectElement, isSelectElement,
isStyleElement, isStyleElement,
isSVGElementNode,
isTextareaElement, isTextareaElement,
isTextNode isTextNode
} from './node-parser'; } from './node-parser';
@ -127,7 +129,15 @@ export class DocumentCloner {
return this.createStyleClone(node); return this.createStyleClone(node);
} }
return node.cloneNode(false) as HTMLElement; const clone = node.cloneNode(false) as HTMLElement;
// @ts-ignore
if (isImageElement(clone) && clone.loading === 'lazy') {
// @ts-ignore
clone.loading = 'eager';
}
return clone;
} }
createStyleClone(node: HTMLStyleElement): HTMLStyleElement { createStyleClone(node: HTMLStyleElement): HTMLStyleElement {
@ -409,10 +419,17 @@ export class DocumentCloner {
}); });
anonymousReplacedElement.className = `${PSEUDO_HIDE_ELEMENT_CLASS_BEFORE} ${PSEUDO_HIDE_ELEMENT_CLASS_AFTER}`; anonymousReplacedElement.className = `${PSEUDO_HIDE_ELEMENT_CLASS_BEFORE} ${PSEUDO_HIDE_ELEMENT_CLASS_AFTER}`;
clone.className += const newClassName =
pseudoElt === PseudoElementType.BEFORE pseudoElt === PseudoElementType.BEFORE
? ` ${PSEUDO_HIDE_ELEMENT_CLASS_BEFORE}` ? ` ${PSEUDO_HIDE_ELEMENT_CLASS_BEFORE}`
: ` ${PSEUDO_HIDE_ELEMENT_CLASS_AFTER}`; : ` ${PSEUDO_HIDE_ELEMENT_CLASS_AFTER}`;
if (isSVGElementNode(clone)) {
clone.className.baseValue += newClassName;
} else {
clone.className += newClassName;
}
return anonymousReplacedElement; return anonymousReplacedElement;
} }

View File

@ -103,7 +103,8 @@ export const isTextNode = (node: Node): node is Text => node.nodeType === Node.T
export const isElementNode = (node: Node): node is Element => node.nodeType === Node.ELEMENT_NODE; export const isElementNode = (node: Node): node is Element => node.nodeType === Node.ELEMENT_NODE;
export const isHTMLElementNode = (node: Node): node is HTMLElement => export const isHTMLElementNode = (node: Node): node is HTMLElement =>
typeof (node as HTMLElement).style !== 'undefined'; typeof (node as HTMLElement).style !== 'undefined';
export const isSVGElementNode = (element: Element): element is SVGElement =>
typeof (element as SVGElement).className === 'object';
export const isLIElement = (node: Element): node is HTMLLIElement => node.tagName === 'LI'; export const isLIElement = (node: Element): node is HTMLLIElement => node.tagName === 'LI';
export const isOLElement = (node: Element): node is HTMLOListElement => node.tagName === 'OL'; export const isOLElement = (node: Element): node is HTMLOListElement => node.tagName === 'OL';
export const isInputElement = (node: Element): node is HTMLInputElement => node.tagName === 'INPUT'; export const isInputElement = (node: Element): node is HTMLInputElement => node.tagName === 'INPUT';

View File

@ -25,7 +25,9 @@ const html2canvas = (element: HTMLElement, options: Partial<Options> = {}): Prom
export default html2canvas; export default html2canvas;
CacheStorage.setContext(window); if (typeof window !== 'undefined') {
CacheStorage.setContext(window);
}
const renderElement = async (element: HTMLElement, opts: Partial<Options>): Promise<HTMLCanvasElement> => { const renderElement = async (element: HTMLElement, opts: Partial<Options>): Promise<HTMLCanvasElement> => {
const ownerDocument = element.ownerDocument; const ownerDocument = element.ownerDocument;

View File

@ -7,6 +7,7 @@
</head> </head>
<body> <body>
<img src="../../assets/image.jpg" /> <img src="../../assets/image.jpg" />
<img src="../../assets/image.jpg" loading="lazy" />
<img src="../../assets/image.jpg" style="width:50px;height:400px;" /> <img src="../../assets/image.jpg" style="width:50px;height:400px;" />
<img src="../../assets/image.jpg" style="width:500px;" /> <img src="../../assets/image.jpg" style="width:500px;" />
<img src="../../assets/image.jpg" style="width:100px;border-radius:50px;" /> <img src="../../assets/image.jpg" style="width:100px;border-radius:50px;" />

View File

@ -11,13 +11,16 @@
body { body {
font-family: Arial; font-family: Arial;
} }
svg:before {
content: " ";
}
</style> </style>
</head> </head>
<body> <body>
<div> <div>
<img src="../../../assets/image.svg" /> <img src="../../../assets/image.svg" />
<img width="200" height="200" src='data:image/svg+xml,<svg xmlns:svg="http://www.w3.org/2000/svg" xmlns="http://www.w3.org/2000/svg" version="1.1" width="306" height="296"><defs id="defs4" /><g transform="translate(-162.46995,-477.2863)" id="layer1"><path d="m 314.15745,481.69558 c -59.20089,0.53774 -114.80979,36.72219 -137.3125,95.34375 -29.39129,76.56693 8.83932,162.45246 85.40625,191.84375 l 34.03125,-88.6875 c -20.0678,-7.71358 -34.3125,-27.15324 -34.3125,-49.9375 0,-29.54723 23.95277,-53.5 53.5,-53.5 29.54723,0 53.5,23.95277 53.5,53.5 0,22.78426 -14.2447,42.22392 -34.3125,49.9375 l 34.03125,88.6875 c 39.29085,-15.08234 70.3239,-46.1154 85.40625,-85.40625 29.39129,-76.56693 -8.83932,-162.48371 -85.40625,-191.875 -17.94537,-6.88859 -36.40853,-10.07087 -54.53125,-9.90625 z" id="path2830" style="fill:#40aa54;fill-opacity:1;stroke:#20552a;stroke-width:7.99999952;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none" /></g></svg>' /> <img width="200" height="200" src='data:image/svg+xml,<svg xmlns:svg="http://www.w3.org/2000/svg" xmlns="http://www.w3.org/2000/svg" version="1.1" width="306" height="296"><defs id="defs4" /><g transform="translate(-162.46995,-477.2863)" id="layer1"><path d="m 314.15745,481.69558 c -59.20089,0.53774 -114.80979,36.72219 -137.3125,95.34375 -29.39129,76.56693 8.83932,162.45246 85.40625,191.84375 l 34.03125,-88.6875 c -20.0678,-7.71358 -34.3125,-27.15324 -34.3125,-49.9375 0,-29.54723 23.95277,-53.5 53.5,-53.5 29.54723,0 53.5,23.95277 53.5,53.5 0,22.78426 -14.2447,42.22392 -34.3125,49.9375 l 34.03125,88.6875 c 39.29085,-15.08234 70.3239,-46.1154 85.40625,-85.40625 29.39129,-76.56693 -8.83932,-162.48371 -85.40625,-191.875 -17.94537,-6.88859 -36.40853,-10.07087 -54.53125,-9.90625 z" id="path2830" style="fill:#40aa54;fill-opacity:1;stroke:#20552a;stroke-width:7.99999952;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none" /></g></svg>' />
<svg xmlns="http://www.w3.org/2000/svg" version="1.1" width="306" height="296" id="svg2"> <svg xmlns="http://www.w3.org/2000/svg" version="1.1" width="306" height="296" id="svg2" class="test">
<defs id="defs4"/> <defs id="defs4"/>
<g transform="translate(-162.46995,-477.2863)" id="layer1"> <g transform="translate(-162.46995,-477.2863)" id="layer1">
<path d="m 314.15745,481.69558 c -59.20089,0.53774 -114.80979,36.72219 -137.3125,95.34375 -29.39129,76.56693 8.83932,162.45246 85.40625,191.84375 l 34.03125,-88.6875 c -20.0678,-7.71358 -34.3125,-27.15324 -34.3125,-49.9375 0,-29.54723 23.95277,-53.5 53.5,-53.5 29.54723,0 53.5,23.95277 53.5,53.5 0,22.78426 -14.2447,42.22392 -34.3125,49.9375 l 34.03125,88.6875 c 39.29085,-15.08234 70.3239,-46.1154 85.40625,-85.40625 29.39129,-76.56693 -8.83932,-162.48371 -85.40625,-191.875 -17.94537,-6.88859 -36.40853,-10.07087 -54.53125,-9.90625 z" <path d="m 314.15745,481.69558 c -59.20089,0.53774 -114.80979,36.72219 -137.3125,95.34375 -29.39129,76.56693 8.83932,162.45246 85.40625,191.84375 l 34.03125,-88.6875 c -20.0678,-7.71358 -34.3125,-27.15324 -34.3125,-49.9375 0,-29.54723 23.95277,-53.5 53.5,-53.5 29.54723,0 53.5,23.95277 53.5,53.5 0,22.78426 -14.2447,42.22392 -34.3125,49.9375 l 34.03125,88.6875 c 39.29085,-15.08234 70.3239,-46.1154 85.40625,-85.40625 29.39129,-76.56693 -8.83932,-162.48371 -85.40625,-191.875 -17.94537,-6.88859 -36.40853,-10.07087 -54.53125,-9.90625 z"

View File

@ -3,7 +3,8 @@
<head lang="en"> <head lang="en">
<meta charset="UTF-8"> <meta charset="UTF-8">
<title>fontawesome icons</title> <title>fontawesome icons</title>
<link href="//maxcdn.bootstrapcdn.com/font-awesome/4.2.0/css/font-awesome.min.css" rel="stylesheet"> <link href="https://use.fontawesome.com/releases/v5.13.0/css/all.css" rel="stylesheet">
<link href="https://use.fontawesome.com/releases/v5.13.0/css/v4-shims.css" rel="stylesheet">
<script type="text/javascript" src="../../test.js"></script> <script type="text/javascript" src="../../test.js"></script>
<style> <style>
body { body {