Getting rid of elemental.js. Fix for issue #50

master
Dmitry Baranovskiy 2013-10-25 13:59:41 -07:00
parent 36958d25c2
commit d865bf0810
3 changed files with 13 additions and 22 deletions

View File

@ -30,7 +30,6 @@ module.exports = function(grunt) {
"./node_modules/eve/eve.js", "./node_modules/eve/eve.js",
"./src/amd-banner.js", "./src/amd-banner.js",
"./src/mina.js", "./src/mina.js",
"./node_modules/elemental.js/elemental.js",
"./src/svg.js", "./src/svg.js",
"./src/path.js", "./src/path.js",
"./src/set.js", "./src/set.js",

View File

@ -1,6 +1,6 @@
{ {
"name": "Snap.svg", "name": "Snap.svg",
"version": "0.1.0", "version": "0.1.1",
"description": "JavaScript Vector Library", "description": "JavaScript Vector Library",
"main": "Gruntfile.js", "main": "Gruntfile.js",
"repository": { "repository": {
@ -17,7 +17,6 @@
"mocha": "*", "mocha": "*",
"expect.js": "*", "expect.js": "*",
"eve": "*", "eve": "*",
"elemental.js": "~0.2.4",
"dr.js": "~0.0.10" "dr.js": "~0.0.10"
} }
} }

View File

@ -71,6 +71,7 @@ var has = "hasOwnProperty",
objectToString = Object.prototype.toString, objectToString = Object.prototype.toString,
ISURL = /^url\(['"]?([^\)]+?)['"]?\)$/i, ISURL = /^url\(['"]?([^\)]+?)['"]?\)$/i,
colourRegExp = /^\s*((#[a-f\d]{6})|(#[a-f\d]{3})|rgba?\(\s*([\d\.]+%?\s*,\s*[\d\.]+%?\s*,\s*[\d\.]+%?(?:\s*,\s*[\d\.]+%?)?)\s*\)|hsba?\(\s*([\d\.]+(?:deg|\xb0|%)?\s*,\s*[\d\.]+%?\s*,\s*[\d\.]+(?:%?\s*,\s*[\d\.]+)?%?)\s*\)|hsla?\(\s*([\d\.]+(?:deg|\xb0|%)?\s*,\s*[\d\.]+%?\s*,\s*[\d\.]+(?:%?\s*,\s*[\d\.]+)?%?)\s*\))\s*$/i, colourRegExp = /^\s*((#[a-f\d]{6})|(#[a-f\d]{3})|rgba?\(\s*([\d\.]+%?\s*,\s*[\d\.]+%?\s*,\s*[\d\.]+%?(?:\s*,\s*[\d\.]+%?)?)\s*\)|hsba?\(\s*([\d\.]+(?:deg|\xb0|%)?\s*,\s*[\d\.]+%?\s*,\s*[\d\.]+(?:%?\s*,\s*[\d\.]+)?%?)\s*\)|hsla?\(\s*([\d\.]+(?:deg|\xb0|%)?\s*,\s*[\d\.]+%?\s*,\s*[\d\.]+(?:%?\s*,\s*[\d\.]+)?%?)\s*\))\s*$/i,
isnan = {"NaN": 1, "Infinity": 1, "-Infinity": 1},
bezierrg = /^(?:cubic-)?bezier\(([^,]+),([^,]+),([^,]+),([^\)]+)\)/, bezierrg = /^(?:cubic-)?bezier\(([^,]+),([^,]+),([^,]+),([^\)]+)\)/,
reURLValue = /^url\(#?([^)]+)\)$/, reURLValue = /^url\(#?([^)]+)\)$/,
spaces = "\x09\x0a\x0b\x0c\x0d\x20\xa0\u1680\u180e\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200a\u202f\u205f\u3000\u2028\u2029", spaces = "\x09\x0a\x0b\x0c\x0d\x20\xa0\u1680\u180e\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200a\u202f\u205f\u3000\u2028\u2029",
@ -138,7 +139,7 @@ function getAttrs(el) {
function is(o, type) { function is(o, type) {
type = Str.prototype.toLowerCase.call(type); type = Str.prototype.toLowerCase.call(type);
if (type == "finite") { if (type == "finite") {
return isFinite(o); return !isnan[has](+o);
} }
if (type == "array" && if (type == "array" &&
(o instanceof Array || Array.isArray && Array.isArray(o))) { (o instanceof Array || Array.isArray && Array.isArray(o))) {
@ -2291,24 +2292,16 @@ function arrayFirstValue(arr) {
\*/ \*/
Snap.parse = function (svg) { Snap.parse = function (svg) {
var f = glob.doc.createDocumentFragment(), var f = glob.doc.createDocumentFragment(),
pointer = f; div = glob.doc.createElement("div");
eve.on("elemental.tag", function (data, extra, raw) { svg = "<svg>" + svg + "</svg>";
var tag = $(data); div.innerHTML = svg;
extra && $(tag, extra); svg = div.getElementsByTagName("svg")[0];
pointer.appendChild(tag); if (svg) {
pointer = tag; while (svg.firstChild) {
}); f.appendChild(svg.firstChild);
eve.on("elemental.text", function (text) { }
pointer.appendChild(glob.doc.createTextNode(text)); }
}); div.innerHTML = E;
eve.on("elemental./tag", function () {
pointer = pointer.parentNode;
});
eve.on("elemental.eof", function () {
eve.off("elemental.*");
eve("snap.parsed", f);
});
elemental().parse(svg).end();
return new Fragment(f); return new Fragment(f);
}; };
function Fragment(frag) { function Fragment(frag) {