Commit f81a5bd1 authored by Neil Fraser's avatar Neil Fraser

Expand regex to handle IE's scientific notation.

parent ffe49a70
...@@ -266,12 +266,7 @@ Blockly.getRelativeXY_ = function(element) { ...@@ -266,12 +266,7 @@ Blockly.getRelativeXY_ = function(element) {
} }
// Second, check for transform="translate(...)" attribute. // Second, check for transform="translate(...)" attribute.
var transform = element.getAttribute('transform'); var transform = element.getAttribute('transform');
// Note that Firefox and IE (9,10) return 'translate(12)' instead of var r = transform && transform.match(Blockly.getRelativeXY_.XY_REGEXP_);
// 'translate(12, 0)'.
// Note that IE (9,10) returns 'translate(16 8)' instead of
// 'translate(16, 8)'.
var r = transform &&
transform.match(/translate\(\s*([-\d.]+)([ ,]\s*([-\d.]+)\s*\))?/);
if (r) { if (r) {
xy.x += parseFloat(r[1]); xy.x += parseFloat(r[1]);
if (r[3]) { if (r[3]) {
...@@ -281,6 +276,18 @@ Blockly.getRelativeXY_ = function(element) { ...@@ -281,6 +276,18 @@ Blockly.getRelativeXY_ = function(element) {
return xy; return xy;
}; };
/**
* Static regex to pull the x,y values out of an SVG translate() directive.
* Note that Firefox and IE (9,10) return 'translate(12)' instead of
* 'translate(12, 0)'.
* Note that IE (9,10) returns 'translate(16 8)' instead of 'translate(16, 8)'.
* Note that IE has been reported to return scientific notation (0.123456e-42).
* @type {!RegExp}
* @private
*/
Blockly.getRelativeXY_.XY_REGEXP_ =
/translate\(\s*([-+\d.e]+)([ ,]\s*([-+\d.e]+)\s*\))?/;
/** /**
* Return the absolute coordinates of the top-left corner of this element, * Return the absolute coordinates of the top-left corner of this element,
* scales that after canvas SVG element, if it's a descendant. * scales that after canvas SVG element, if it's a descendant.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment