From b2df50a858060b8c4a5d1a399c13222690c4edf7 Mon Sep 17 00:00:00 2001 From: Niklas von Hertzen Date: Wed, 30 Jan 2013 20:12:25 +0200 Subject: [PATCH 1/5] Allow element node to be passed --- src/Util.js | 1 + 1 file changed, 1 insertion(+) diff --git a/src/Util.js b/src/Util.js index a77c35b..baa0325 100644 --- a/src/Util.js +++ b/src/Util.js @@ -1,4 +1,5 @@ window.html2canvas = function(elements, opts) { + elements = (elements.length) ? elements : [elements]; var queue, canvas, options = { From 2d95a761b00f03b43c4a36e98c57ab44de21cdbc Mon Sep 17 00:00:00 2001 From: Dan Farrelly Date: Thu, 21 Mar 2013 22:40:09 -0400 Subject: [PATCH 2/5] Upgraded to Grunt 0.4.0. --- grunt.js => Gruntfile.js | 17 ++++++++++------- package.json | 10 ++++++++++ 2 files changed, 20 insertions(+), 7 deletions(-) rename grunt.js => Gruntfile.js (82%) diff --git a/grunt.js b/Gruntfile.js similarity index 82% rename from grunt.js rename to Gruntfile.js index 65db9b8..746ddcf 100644 --- a/grunt.js +++ b/Gruntfile.js @@ -12,9 +12,6 @@ module.exports = function(grunt) { pre: '(function(window, document, undefined){', post: '})(window,document);' }, - lint: { - files: ['build/<%= pkg.name %>.js'] - }, qunit: { files: ['tests/qunit/index.html'] }, @@ -24,7 +21,7 @@ module.exports = function(grunt) { dest: 'build/<%= pkg.name %>.js' } }, - min: { + uglify: { dist: { src: ['', ''], dest: 'build/<%= pkg.name %>.min.js' @@ -35,6 +32,7 @@ module.exports = function(grunt) { tasks: 'lint qunit' }, jshint: { + all: ['build/<%= pkg.name %>.js'], options: { curly: true, eqeqeq: true, @@ -51,8 +49,7 @@ module.exports = function(grunt) { globals: { jQuery: true } - }, - uglify: {} + } }); var selenium = require("./tests/selenium.js"); @@ -67,7 +64,13 @@ module.exports = function(grunt) { } }); + // Load tasks + grunt.loadNpmTasks('grunt-contrib-concat'); + grunt.loadNpmTasks('grunt-contrib-uglify'); + grunt.loadNpmTasks('grunt-contrib-jshint'); + grunt.loadNpmTasks('grunt-contrib-qunit'); + // Default task. - grunt.registerTask('default', 'concat lint qunit min webdriver'); + grunt.registerTask('default', ['concat', 'jshint', 'qunit', 'uglify', 'webdriver']); }; diff --git a/package.json b/package.json index 91a07a2..28cb563 100644 --- a/package.json +++ b/package.json @@ -6,11 +6,21 @@ "author": { "name":"Niklas von Hertzen (@niklasvh)" }, + "engines": { + "node": ">=0.8.0" + }, "dependencies": { "base64-arraybuffer": ">= 0.1.0", "png-js": ">= 0.1.1", "webdriver.js": ">= 0.1.0" }, + "devDependencies":{ + "grunt": ">=0.4.0", + "grunt-contrib-concat": "*", + "grunt-contrib-uglify": "*", + "grunt-contrib-jshint": "*", + "grunt-contrib-qunit": "*" + }, "homepage": "http://html2canvas.hertzen.com", "licenses": [{ "type": "MIT" From 8623e4014b0b8af0ea260c686b95394794a17cc8 Mon Sep 17 00:00:00 2001 From: Dan Farrelly Date: Fri, 22 Mar 2013 14:57:38 -0400 Subject: [PATCH 3/5] Upgrade to Grunt 0.4.0 complete. Safari on OSX bug fix. --- Gruntfile.js | 59 +++++++++++++++++++++++++++++++++++----------------- src/Parse.js | 7 ++++++- 2 files changed, 46 insertions(+), 20 deletions(-) diff --git a/Gruntfile.js b/Gruntfile.js index 746ddcf..88faa9e 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -1,38 +1,59 @@ /*global module:false*/ module.exports = function(grunt) { - // Project configuration. - grunt.initConfig({ - pkg: '', - meta: { - banner: '/*\n <%= pkg.title || pkg.name %> <%= pkg.version %>' + - '<%= pkg.homepage ? " <" + pkg.homepage + ">\n" : "" %>' + + var meta = { + banner: '/*\n <%= pkg.title || pkg.name %> <%= pkg.version %>' + + '<%= pkg.homepage ? " <" + pkg.homepage + ">" : "" %>' + '\n' + ' Copyright (c) <%= grunt.template.today("yyyy") %> <%= pkg.author.name %>' + '\n\n Released under <%= _.pluck(pkg.licenses, "type").join(", ") %> License\n*/', - pre: '(function(window, document, undefined){', - post: '})(window,document);' - }, + pre: '\n(function(window, document, undefined){\n\n', + post: '\n})(window,document);' + }; + + // Project configuration. + grunt.initConfig({ + + pkg: grunt.file.readJSON('package.json'), + qunit: { files: ['tests/qunit/index.html'] }, concat: { dist: { - src: ['', '','src/*.js', 'src/renderers/Canvas.js', ''], + src: [ + 'src/Core.js', + 'src/Font.js', + 'src/Generate.js', + 'src/Queue.js', + 'src/Parse.js', + 'src/Preload.js', + 'src/Renderer.js', + 'src/Support.js', + 'src/Util.js', + 'src/renderers/Canvas.js' + ], dest: 'build/<%= pkg.name %>.js' + }, + options:{ + banner: meta.banner + meta.pre, + footer: meta.post } }, uglify: { dist: { - src: ['', ''], + src: ['<%= concat.dist.dest %>'], dest: 'build/<%= pkg.name %>.min.js' + }, + options: { + banner: meta.banner } }, watch: { - files: '', - tasks: 'lint qunit' + files: '<%= lint.files %>', + tasks: 'jshint qunit' }, jshint: { - all: ['build/<%= pkg.name %>.js'], + all: ['<%= concat.dist.dest %>'], options: { curly: true, eqeqeq: true, @@ -44,10 +65,10 @@ module.exports = function(grunt) { undef: true, boss: true, eqnull: true, - browser: true - }, - globals: { - jQuery: true + browser: true, + globals: { + jQuery: true + } } } }); @@ -71,6 +92,6 @@ module.exports = function(grunt) { grunt.loadNpmTasks('grunt-contrib-qunit'); // Default task. - grunt.registerTask('default', ['concat', 'jshint', 'qunit', 'uglify', 'webdriver']); + grunt.registerTask('default', ['jshint', 'concat', 'qunit', 'uglify', 'webdriver']); }; diff --git a/src/Parse.js b/src/Parse.js index de6ec6a..7b14096 100644 --- a/src/Parse.js +++ b/src/Parse.js @@ -775,7 +775,12 @@ _html2canvas.Parse = function (images, options) { elps.className = pseudoHide + "-before " + pseudoHide + "-after"; Object.keys(elStyle).filter(indexedProperty).forEach(function(prop) { - elps.style[prop] = elStyle[prop]; + // Prevent assigning of read only CSS Rules, ex. length, parentRule + try { + elps.style[prop] = elStyle[prop]; + } catch (e) { + h2clog(['Tried to assign readonly property ', prop, 'Error:', e]); + } }); if(isImage) { From cacb9a468fb5459167e723c6ac6dd31fbd2d2de7 Mon Sep 17 00:00:00 2001 From: Dan Farrelly Date: Sat, 23 Mar 2013 20:00:01 -0400 Subject: [PATCH 4/5] Modified markdown function. Added grunt build task. Markdown format output currently commented out. --- .DS_Store | Bin 0 -> 6148 bytes Gruntfile.js | 1 + tests/readme.md | 70 +++++++++++++++++++++++----------------------- tests/selenium.js | 55 ++++++++++++++++++++++++++++-------- 4 files changed, 79 insertions(+), 47 deletions(-) create mode 100644 .DS_Store diff --git a/.DS_Store b/.DS_Store new file mode 100644 index 0000000000000000000000000000000000000000..5008ddfcf53c02e82d7eee2e57c38e5672ef89f6 GIT binary patch literal 6148 zcmeH~Jr2S!425mzP>H1@V-^m;4Wg<&0T*E43hX&L&p$$qDprKhvt+--jT7}7np#A3 zem<@ulZcFPQ@L2!n>{z**++&mCkOWA81W14cNZlEfg7;MkzE(HCqgga^y>{tEnwC%0;vJ&^%eQ zLs35+`xjp>T0chrome
23.0.1271.97firefox
12.0iexplorer
9 -background/clip.html100%100%99.89% -background/encoded.html100%100%100% -background/linear-gradient.html89.87%90.73%100% -background/multi.html100%100%99.93% -background/position.html100%100%99.87% -background/radial-gradient.html73.23%70.32%94.02% -background/repeat.html100%100%99.92% -border/dashed.html96.45%98.38%97.7% -border/dotted.html97.41%96.46%95.93% -border/double.html97.96%97.87%97.95% -border/radius.html99.74%99.77%99.75% -border/solid.html99.97%99.97%99.98% -forms.html95.96%94.55%95.01% -images/canvas.html99.86%100%100% -images/cross-origin.html97.99%97.58%99.35% -images/empty.html99.86%99.87%99.85% -images/images.html83.72%96.93%55.09% -images/svg.html99.92%96.79%99.93% -list/decimal-leading-zero.html99.63%99.72%35.88% -list/decimal.html99.64%99.73%35.89% -list/lower-alpha.html99.65%99.73%35.89% -list/upper-roman.html99.45%99.61%35.94% -overflow.html96.85%97.49%96.5% -pseudoelements.html97.36%97.94%99.37% -text/chinese.html99.75%99.74%65.76% -text/linethrough.html97.14%94.12%47.08% -text/text.html95.71%94.67%85.01% -text/underline-lineheight.html97.06%92.35%53% -text/underline.html97.65%93.5%47.02% -visibility.html99.19%98.92%99.39% -zindex/z-index1.html96.99%99.27%99.44% -zindex/z-index2.html95.85%98.06%97.72% -zindex/z-index3.html98.6%98.29%98.56% - \ No newline at end of file + + + + + + + + + + + + + + + + + + + + + + + + + + + +b + + + + + + +
chrome
23.0.1271.97
firefox
12.0
iexplorer
9
chrome
25.0.1364.172
Mac 10.7.4
firefox
19.0.2
Mac 10.7.4
safari
6.0
Mac 10.7.4
background/clip.html100%100%99.89%100%100%100%
background/encoded.html100%100%100%100%100%100%
background/linear-gradient.html89.87%90.73%100%95.35%91.33%91.69%
background/multi.html100%100%99.93%100%100%100%
background/position.html100%100%99.87%100%100%100%
background/radial-gradient.html73.23%70.32%94.02%87.65%57.99%79.95%
background/repeat.html100%100%99.92%100%100%100%
border/dashed.html96.45%98.38%97.7%98.36%98.47%97.43%
border/dotted.html97.41%96.46%95.93%98.81%96.31%98.13%
border/double.html97.96%97.87%97.95%99.06%97.99%98.53%
border/radius.html99.74%99.77%99.75%99.88%99.81%99.75%
border/solid.html99.97%99.97%99.98%99.99%99.97%99.98%
forms.html95.96%94.55%95.01%98.57%94.2%97.69%
images/canvas.html99.86%100%100%99.93%100%99.87%
images/cross-origin.html97.99%97.58%99.35%99.7%98.41%99.89%
images/empty.html99.86%99.87%99.85%99.91%99.81%99.86%
images/images.html83.72%96.93%55.09%92.45%95.81%87.06%
images/svg.html99.92%96.79%99.93%99.95%96.51%99.92%
list/decimal-leading-zero.html99.63%99.72%35.88%99.7%99.99%15.05%
list/decimal.html99.64%99.73%35.89%99.71%99.99%15.06%
list/lower-alpha.html99.65%99.73%35.89%99.72%99.98%15.06%
list/upper-roman.html99.45%99.61%35.94%99.59%99.99%13.97%
overflow.html96.85%97.49%96.5%98.15%97.96%99.42%
pseudoelements.html97.36%97.94%99.37%98.73%97.81%98.29%
text/chinese.html99.75%99.74%65.76%93.93%96%46.75%
text/linethrough.html97.14%94.12%47.08%98.99%90.28%31.02%
text/text.html95.71%94.67%85.01%96.83%95.6%94.63%
text/underline-lineheight.html97.06%92.35%53%99.15%93.69%40.76%
text/underline.html97.65%93.5%47.02%99.35%89.85%31.07%
visibility.html99.19%98.92%99.39%99.69%99.32%99.74%
zindex/z-index1.html96.99%99.27%99.44%98.62%98.48%98%
zindex/z-index2.html95.85%98.06%97.72%97.79%96.69%96.72%
zindex/z-index3.html98.6%98.29%98.56%99.35%96.49%97.92%
diff --git a/tests/selenium.js b/tests/selenium.js index 8f7bc88..e8ad78e 100644 --- a/tests/selenium.js +++ b/tests/selenium.js @@ -99,7 +99,7 @@ } done(100 - (Math.round((diff/h2cPixels.length) * 10000) / 100)); }); - }) + }); }); }); }); @@ -247,26 +247,57 @@ }; exports.markdown = function() { - var data = {}, html = "", - browsers = ["chrome", "firefox", "iexplorer"]; + var data = {}, + html = "
", + md = " | ", + browsers = ["chrome", "firefox", "iexplorer", "safari"], + activeBrowsers = []; + // Create row for browsers browsers.forEach(function(browser) { - data[browser] = JSON.parse(fs.readFileSync("tests/results/" + browser + ".json")); - html += ""; - }); - html += "\n"; - Object.keys(data[browsers[0]].tests).forEach(function(testFile) { + if (fs.existsSync("tests/results/" + browser + ".json")) { + + var fileContents = fs.readFileSync("tests/results/" + browser + ".json"); + data[browser] = JSON.parse(fileContents); + + activeBrowsers.push(browser); + + html += ""; + md += browser + data[browser].version + " | "; + } else { + console.log("Browser report not found. ", browser + ".json"); + } + + }); + + html += "\n"; + md += "\n ----"; + for (var i = activeBrowsers.length - 1; i >= 0; i--) { + md += "|---- "; + } + md += "\n"; + + Object.keys(data[activeBrowsers[0]].tests).forEach(function(testFile) { + html += ""; - browsers.forEach(function(browser) { - html += ""; + md += testFile.substring(12); + activeBrowsers.forEach(function(activeBrowsers) { + html += ""; + md += " | " + Math.round(data[activeBrowsers].tests[testFile] * 100) / 100 + "%"; }); - html += "\n" + html += "\n"; + md += "\n"; }); html += "
" + browser + "
" + data[browser].version + "
" + browser + "
" + data[browser].version + "
" + testFile.substring(12) + "" + Math.round(data[browser].tests[testFile] * 100) / 100 + "%" + Math.round(data[activeBrowsers].tests[testFile] * 100) / 100 + "%
"; - fs.writeFileSync("tests/readme.md", html); + // if (isMarkdown){ + // fs.writeFileSync("tests/readme.md", md); + // } else { + fs.writeFileSync("tests/readme.md", html); + // } + }; })(); \ No newline at end of file From 5ac4b42e33deb1f97a997fb13d2c56912eaa3ac1 Mon Sep 17 00:00:00 2001 From: Dan Farrelly Date: Sat, 23 Mar 2013 20:06:31 -0400 Subject: [PATCH 5/5] Added reference to build shortcut on readme.md --- readme.md | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/readme.md b/readme.md index 9ae1234..4148384 100644 --- a/readme.md +++ b/readme.md @@ -50,8 +50,7 @@ Run the full build process (including lint, qunit and webdriver tests): Skip lint and tests and simply build from source: - $ grunt concat - $ grunt min + $ grunt build ### Running tests ###