diff --git a/src/Core.js b/src/Core.js
index 5ec0ef0..6928517 100644
--- a/src/Core.js
+++ b/src/Core.js
@@ -14,6 +14,13 @@ function h2clog(a) {
 
 _html2canvas.Util = {};
 
+_html2canvas.Util.trimText = (function(native){ 
+  return function(input){
+    if(native) { return native.apply( input ); }
+    else { return ((input || '') + '').replace( /^\s+|\s+$/ , '' ); }
+  };
+})( String.prototype.trim );
+
 _html2canvas.Util.parseBackgroundImage = function (value) {
     var whitespace = ' \r\n\t',
         method, definition, prefix, prefix_i, block, results = [], 
@@ -188,15 +195,17 @@ _html2canvas.Util.getCSS = function (el, attribute, index) {
     val = computedCSS[ attribute ];
 
     if ( isBackgroundSizePosition ) {
-      val = (val || '').split(',');
+      val = (val || '').split( ',' );
       val = val[index || 0] || val[0] || 'auto';
-      val = val.split(' ');
-      if(attribute === 'backgroundSize' && (!val[0] || val[0].match(/cover|contain|auto/))) {
+      val = _html2canvas.Util.trimText( val ).split( ' ' );
+      
+      if(attribute === 'backgroundSize' && (!val[ 0 ] || val[ 0 ].match( /cover|contain|auto/ ))) {
+        //these values will be handled in the parent function
 
       } else {
-        val[ 0 ] = ( val[0].indexOf( "%" ) === -1 ) ? toPX(  attribute + "X", val[ 0 ] ) : val[ 0 ];
-        val[ 1 ] = ( val[1] === undefined ) ? val[0] : val[1]; // IE 9 doesn't return double digit always
-        val[ 1 ] = ( val[1].indexOf( "%" ) === -1 ) ? toPX(  attribute + "Y", val[ 1 ] ) : val[ 1 ];
+        val[ 0 ] = ( val[ 0 ].indexOf( "%" ) === -1 ) ? toPX(  attribute + "X", val[ 0 ] ) : val[ 0 ];
+        val[ 1 ] = ( val[ 1 ] === undefined ) ? val[ 0 ] : val[ 1 ]; // IE 9 doesn't return double digit always
+        val[ 1 ] = ( val[ 1 ].indexOf( "%" ) === -1 ) ? toPX(  attribute + "Y", val[ 1 ] ) : val[ 1 ];
       }
     } else if ( /border(Top|Bottom)(Left|Right)Radius/.test( attribute) ) {
       var arr = val.split(" ");
diff --git a/src/Parse.js b/src/Parse.js
index 66b056f..e005ebf 100644
--- a/src/Parse.js
+++ b/src/Parse.js
@@ -61,12 +61,8 @@ _html2canvas.Parse = function (images, options) {
     return (/^(normal|none|0px)$/.test(letter_spacing));
   }
 
-  function trimText (text) {
-    return text.replace(/^\s*/g, "").replace(/\s*$/g, "");
-  }
-
   function drawText(currentText, x, y, ctx){
-    if (currentText !== null && trimText(currentText).length > 0) {
+    if (currentText !== null && _html2canvas.Util.trimText(currentText).length > 0) {
       ctx.fillText(currentText, x, y);
       numDraws+=1;
     }
@@ -116,7 +112,7 @@ _html2canvas.Parse = function (images, options) {
   function getTextBounds(state, text, textDecoration, isLast) {
     var bounds;
     if (support.rangeBounds) {
-      if (textDecoration !== "none" || trimText(text).length !== 0) {
+      if (textDecoration !== "none" || _html2canvas.Util.trimText(text).length !== 0) {
         bounds = textRangeBounds(text, state.node, state.textOffset);
       }
       state.textOffset += text.length;
@@ -160,7 +156,7 @@ _html2canvas.Parse = function (images, options) {
       textOffset: 0
     };
 
-    if (trimText(textNode.nodeValue).length > 0) {
+    if (_html2canvas.Util.trimText(textNode.nodeValue).length > 0) {
       textNode.nodeValue = textTransform(textNode.nodeValue, getCSS(el, "textTransform"));
       textAlign = textAlign.replace(["-webkit-auto"],["auto"]);