Skip to content

Commit 4ebe9c5

Browse files
committed
Don't require logger to be exposed to window object
1 parent e17bbac commit 4ebe9c5

File tree

6 files changed

+19329
-78
lines changed

6 files changed

+19329
-78
lines changed

dist/html2canvas.js

Lines changed: 43 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,21 @@
11
/*
2-
html2canvas 0.5.0-beta2 <http://html2canvas.hertzen.com>
3-
Copyright (c) 2015 Niklas von Hertzen
2+
html2canvas 0.5.0-beta3 <http://html2canvas.hertzen.com>
3+
Copyright (c) 2016 Niklas von Hertzen
44
55
Released under License
66
*/
77

8-
(function(f){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=f()}else if(typeof define==="function"&&define.amd){define([],f)}else{var g;if(typeof window!=="undefined"){g=window}else if(typeof global!=="undefined"){g=global}else if(typeof self!=="undefined"){g=self}else{g=this}g.html2canvas = f()}})(function(){var define,module,exports;return (function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(require,module,exports){
8+
!function(e){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=e();else if("function"==typeof define&&define.amd)define([],e);else{var f;"undefined"!=typeof window?f=window:"undefined"!=typeof global?f=global:"undefined"!=typeof self&&(f=self),f.html2canvas=e()}}(function(){var define,module,exports;return (function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(require,module,exports){
99
(function (global){
10-
/*! https://mths.be/punycode v1.3.2 by @mathias */
10+
/*! http://mths.be/punycode v1.2.4 by @mathias */
1111
;(function(root) {
1212

1313
/** Detect free variables */
14-
var freeExports = typeof exports == 'object' && exports &&
15-
!exports.nodeType && exports;
14+
var freeExports = typeof exports == 'object' && exports;
1615
var freeModule = typeof module == 'object' && module &&
17-
!module.nodeType && module;
16+
module.exports == freeExports && module;
1817
var freeGlobal = typeof global == 'object' && global;
19-
if (
20-
freeGlobal.global === freeGlobal ||
21-
freeGlobal.window === freeGlobal ||
22-
freeGlobal.self === freeGlobal
23-
) {
18+
if (freeGlobal.global === freeGlobal || freeGlobal.window === freeGlobal) {
2419
root = freeGlobal;
2520
}
2621

@@ -46,8 +41,8 @@
4641

4742
/** Regular expressions */
4843
regexPunycode = /^xn--/,
49-
regexNonASCII = /[^\x20-\x7E]/, // unprintable ASCII chars + non-ASCII chars
50-
regexSeparators = /[\x2E\u3002\uFF0E\uFF61]/g, // RFC 3490 separators
44+
regexNonASCII = /[^ -~]/, // unprintable ASCII chars + non-ASCII chars
45+
regexSeparators = /\x2E|\u3002|\uFF0E|\uFF61/g, // RFC 3490 separators
5146

5247
/** Error messages */
5348
errors = {
@@ -86,37 +81,23 @@
8681
*/
8782
function map(array, fn) {
8883
var length = array.length;
89-
var result = [];
9084
while (length--) {
91-
result[length] = fn(array[length]);
85+
array[length] = fn(array[length]);
9286
}
93-
return result;
87+
return array;
9488
}
9589

9690
/**
97-
* A simple `Array#map`-like wrapper to work with domain name strings or email
98-
* addresses.
91+
* A simple `Array#map`-like wrapper to work with domain name strings.
9992
* @private
100-
* @param {String} domain The domain name or email address.
93+
* @param {String} domain The domain name.
10194
* @param {Function} callback The function that gets called for every
10295
* character.
10396
* @returns {Array} A new string of characters returned by the callback
10497
* function.
10598
*/
10699
function mapDomain(string, fn) {
107-
var parts = string.split('@');
108-
var result = '';
109-
if (parts.length > 1) {
110-
// In email addresses, only the domain name should be punycoded. Leave
111-
// the local part (i.e. everything up to `@`) intact.
112-
result = parts[0] + '@';
113-
string = parts[1];
114-
}
115-
// Avoid `split(regex)` for IE8 compatibility. See #17.
116-
string = string.replace(regexSeparators, '\x2E');
117-
var labels = string.split('.');
118-
var encoded = map(labels, fn).join('.');
119-
return result + encoded;
100+
return map(string.split(regexSeparators), fn).join('.');
120101
}
121102

122103
/**
@@ -126,7 +107,7 @@
126107
* UCS-2 exposes as separate characters) into a single code point,
127108
* matching UTF-16.
128109
* @see `punycode.ucs2.encode`
129-
* @see <https://mathiasbynens.be/notes/javascript-encoding>
110+
* @see <http://mathiasbynens.be/notes/javascript-encoding>
130111
* @memberOf punycode.ucs2
131112
* @name decode
132113
* @param {String} string The Unicode input string (UCS-2).
@@ -335,8 +316,8 @@
335316
}
336317

337318
/**
338-
* Converts a string of Unicode symbols (e.g. a domain name label) to a
339-
* Punycode string of ASCII-only symbols.
319+
* Converts a string of Unicode symbols to a Punycode string of ASCII-only
320+
* symbols.
340321
* @memberOf punycode
341322
* @param {String} input The string of Unicode symbols.
342323
* @returns {String} The resulting Punycode string of ASCII-only symbols.
@@ -449,37 +430,33 @@
449430
}
450431

451432
/**
452-
* Converts a Punycode string representing a domain name or an email address
453-
* to Unicode. Only the Punycoded parts of the input will be converted, i.e.
454-
* it doesn't matter if you call it on a string that has already been
455-
* converted to Unicode.
433+
* Converts a Punycode string representing a domain name to Unicode. Only the
434+
* Punycoded parts of the domain name will be converted, i.e. it doesn't
435+
* matter if you call it on a string that has already been converted to
436+
* Unicode.
456437
* @memberOf punycode
457-
* @param {String} input The Punycoded domain name or email address to
458-
* convert to Unicode.
438+
* @param {String} domain The Punycode domain name to convert to Unicode.
459439
* @returns {String} The Unicode representation of the given Punycode
460440
* string.
461441
*/
462-
function toUnicode(input) {
463-
return mapDomain(input, function(string) {
442+
function toUnicode(domain) {
443+
return mapDomain(domain, function(string) {
464444
return regexPunycode.test(string)
465445
? decode(string.slice(4).toLowerCase())
466446
: string;
467447
});
468448
}
469449

470450
/**
471-
* Converts a Unicode string representing a domain name or an email address to
472-
* Punycode. Only the non-ASCII parts of the domain name will be converted,
473-
* i.e. it doesn't matter if you call it with a domain that's already in
474-
* ASCII.
451+
* Converts a Unicode string representing a domain name to Punycode. Only the
452+
* non-ASCII parts of the domain name will be converted, i.e. it doesn't
453+
* matter if you call it with a domain that's already in ASCII.
475454
* @memberOf punycode
476-
* @param {String} input The domain name or email address to convert, as a
477-
* Unicode string.
478-
* @returns {String} The Punycode representation of the given domain name or
479-
* email address.
455+
* @param {String} domain The domain name to convert, as a Unicode string.
456+
* @returns {String} The Punycode representation of the given domain name.
480457
*/
481-
function toASCII(input) {
482-
return mapDomain(input, function(string) {
458+
function toASCII(domain) {
459+
return mapDomain(domain, function(string) {
483460
return regexNonASCII.test(string)
484461
? 'xn--' + encode(string)
485462
: string;
@@ -495,11 +472,11 @@
495472
* @memberOf punycode
496473
* @type String
497474
*/
498-
'version': '1.3.2',
475+
'version': '1.2.4',
499476
/**
500477
* An object of methods to convert from JavaScript's internal character
501478
* representation (UCS-2) to Unicode code points, and back.
502-
* @see <https://mathiasbynens.be/notes/javascript-encoding>
479+
* @see <http://mathiasbynens.be/notes/javascript-encoding>
503480
* @memberOf punycode
504481
* @type Object
505482
*/
@@ -524,8 +501,8 @@
524501
define('punycode', function() {
525502
return punycode;
526503
});
527-
} else if (freeExports && freeModule) {
528-
if (module.exports == freeExports) { // in Node.js or RingoJS v0.8.0+
504+
} else if (freeExports && !freeExports.nodeType) {
505+
if (freeModule) { // in Node.js or RingoJS v0.8.0+
529506
freeModule.exports = punycode;
530507
} else { // in Narwhal or RingoJS v0.7.0-
531508
for (key in punycode) {
@@ -938,8 +915,8 @@ function html2canvas(nodeList, options) {
938915
var index = html2canvasCloneIndex++;
939916
options = options || {};
940917
if (options.logging) {
941-
window.html2canvas.logging = true;
942-
window.html2canvas.start = Date.now();
918+
log.options.logging = true;
919+
log.options.start = Date.now();
943920
}
944921

945922
options.async = typeof(options.async) === "undefined" ? true : options.async;
@@ -1509,12 +1486,15 @@ LinearGradientContainer.REGEXP_DIRECTION = /^\s*(?:to|left|right|top|bottom|cent
15091486
module.exports = LinearGradientContainer;
15101487

15111488
},{"./color":3,"./gradientcontainer":9}],13:[function(require,module,exports){
1512-
module.exports = function() {
1513-
if (window.html2canvas.logging && window.console && window.console.log) {
1514-
Function.prototype.bind.call(window.console.log, (window.console)).apply(window.console, [(Date.now() - window.html2canvas.start) + "ms", "html2canvas:"].concat([].slice.call(arguments, 0)));
1489+
var logger = function() {
1490+
if (logger.options.logging && window.console && window.console.log) {
1491+
Function.prototype.bind.call(window.console.log, (window.console)).apply(window.console, [(Date.now() - logger.options.start) + "ms", "html2canvas:"].concat([].slice.call(arguments, 0)));
15151492
}
15161493
};
15171494

1495+
logger.options = {logging: false};
1496+
module.exports = logger;
1497+
15181498
},{}],14:[function(require,module,exports){
15191499
var Color = require('./color');
15201500
var utils = require('./utils');

dist/html2canvas.min.js

Lines changed: 4 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)