mirror of
https://github.com/niklasvh/html2canvas.git
synced 2023-08-10 21:13:10 +03:00
parse out prefixed methods
This commit is contained in:
parent
a4b7d04e80
commit
04782c1716
14
src/Core.js
14
src/Core.js
@ -37,12 +37,20 @@ _html2canvas.Util.parseBackgroundImage = function (value) {
|
||||
if(!value) { return results; }
|
||||
|
||||
while( n++ < 100 && !!(match = value.match(rxBackgroundImage)) ) {
|
||||
var def = match[2];
|
||||
var def = match[2],
|
||||
method = match[1],
|
||||
prefix = '', i;
|
||||
if(def.substr( 0, 1 ) === '"') {
|
||||
def = def.substr(1, def.length-2);
|
||||
def = def.substr( 1, def.length-2 );
|
||||
}
|
||||
if(method.substr( 0, 1 ) === '-' &&
|
||||
(i = method.indexOf( '-', 1 ) + 1) > 0) {
|
||||
prefix = method.substr( 0, i);
|
||||
method = method.substr( i );
|
||||
}
|
||||
results.push({
|
||||
method: match[1],
|
||||
prefix: prefix,
|
||||
method: method,
|
||||
definition: def,
|
||||
value: match[0]
|
||||
});
|
||||
|
@ -148,20 +148,20 @@ $(function() {
|
||||
test('background-image', function () {
|
||||
test_parse_background_image(
|
||||
'url(test)',
|
||||
{ method: 'url', definition: 'test', value: 'url(test)' },
|
||||
{ prefix: '', method: 'url', definition: 'test', value: 'url(test)' },
|
||||
'basic url'
|
||||
);
|
||||
|
||||
test_parse_background_image(
|
||||
'url("test")',
|
||||
{ method: 'url', definition: 'test', value: 'url("test")' },
|
||||
{ prefix: '', method: 'url', definition: 'test', value: 'url("test")' },
|
||||
'quoted url'
|
||||
);
|
||||
|
||||
test_parse_background_image(
|
||||
'url(data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7)',
|
||||
{
|
||||
method: 'url',
|
||||
prefix: '', method: 'url',
|
||||
definition: 'data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7',
|
||||
value: 'url(data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7)'
|
||||
},
|
||||
@ -170,15 +170,21 @@ $(function() {
|
||||
|
||||
test_parse_background_image(
|
||||
'linear-gradient(red,black)',
|
||||
{ method: 'linear-gradient', definition: 'red,black', value: 'linear-gradient(red,black)' },
|
||||
{ prefix: '', method: 'linear-gradient', definition: 'red,black', value: 'linear-gradient(red,black)' },
|
||||
'linear-gradient'
|
||||
);
|
||||
|
||||
test_parse_background_image(
|
||||
'-webkit-linear-gradient(red,black)',
|
||||
{ prefix: '-webkit-', method: 'linear-gradient', definition: 'red,black', value: '-webkit-linear-gradient(red,black)' },
|
||||
'linear-gradient'
|
||||
);
|
||||
|
||||
test_parse_background_image(
|
||||
'linear-gradient(red,black), url(test), url("test")', [
|
||||
{ method: 'linear-gradient', definition: 'red,black', value: 'linear-gradient(red,black)' },
|
||||
{ method: 'url', definition: 'test', value: 'url(test)' },
|
||||
{ method: 'url', definition: 'test', value: 'url("test")' }
|
||||
{ prefix: '', method: 'linear-gradient', definition: 'red,black', value: 'linear-gradient(red,black)' },
|
||||
{ prefix: '', method: 'url', definition: 'test', value: 'url(test)' },
|
||||
{ prefix: '', method: 'url', definition: 'test', value: 'url("test")' }
|
||||
],
|
||||
'multiple backgrounds'
|
||||
);
|
||||
|
Loading…
Reference in New Issue
Block a user