Restore elemental removal. For attr() moved from white list to black list strategy

master
Dmitry Baranovskiy 2013-11-18 11:17:17 +11:00
parent 4e1abf8714
commit c60429c1b7
4 changed files with 585 additions and 850 deletions

File diff suppressed because one or more lines are too long

899
dist/snap.svg.js vendored
View File

@ -14,7 +14,7 @@
// See the License for the specific language governing permissions and // See the License for the specific language governing permissions and
// limitations under the License. // limitations under the License.
// //
// build: 2013-10-30 // build: 2013-11-18
// Copyright (c) 2013 Adobe Systems Incorporated. All rights reserved. // Copyright (c) 2013 Adobe Systems Incorporated. All rights reserved.
// //
// Licensed under the Apache License, Version 2.0 (the "License"); // Licensed under the Apache License, Version 2.0 (the "License");
@ -759,8 +759,7 @@ var mina = (function (eve) {
// limitations under the License. // limitations under the License.
var Snap = (function() { var Snap = (function() {
Snap.version = "0.1.0"; Snap.version = "0.1.1";
// SIERRA: this method appears to be missing from HTML output
/*\ /*\
* Snap * Snap
[ method ] [ method ]
@ -833,6 +832,7 @@ var has = "hasOwnProperty",
return idprefix + (idgen++).toString(36); return idprefix + (idgen++).toString(36);
}, },
xlink = "http://www.w3.org/1999/xlink", xlink = "http://www.w3.org/1999/xlink",
xmlns = "http://www.w3.org/2000/svg",
hub = {}; hub = {};
function $(el, attr) { function $(el, attr) {
@ -844,6 +844,9 @@ function $(el, attr) {
if (attr.substring(0, 6) == "xlink:") { if (attr.substring(0, 6) == "xlink:") {
return el.getAttributeNS(xlink, attr.substring(6)); return el.getAttributeNS(xlink, attr.substring(6));
} }
if (attr.substring(0, 4) == "xml:") {
return el.getAttributeNS(xmlns, attr.substring(4));
}
return el.getAttribute(attr); return el.getAttribute(attr);
} }
for (var key in attr) if (attr[has](key)) { for (var key in attr) if (attr[has](key)) {
@ -851,6 +854,8 @@ function $(el, attr) {
if (val) { if (val) {
if (key.substring(0, 6) == "xlink:") { if (key.substring(0, 6) == "xlink:") {
el.setAttributeNS(xlink, key.substring(6), val); el.setAttributeNS(xlink, key.substring(6), val);
} else if (key.substring(0, 4) == "xml:") {
el.setAttributeNS(xmlns, key.substring(4), val);
} else { } else {
el.setAttribute(key, val); el.setAttribute(key, val);
} }
@ -859,7 +864,7 @@ function $(el, attr) {
} }
} }
} else { } else {
el = glob.doc.createElementNS("http://www.w3.org/2000/svg", el); el = glob.doc.createElementNS(xmlns, el);
// el.style && (el.style.webkitTapHighlightColor = "rgba(0,0,0,0)"); // el.style && (el.style.webkitTapHighlightColor = "rgba(0,0,0,0)");
} }
return el; return el;
@ -3025,26 +3030,18 @@ function arrayFirstValue(arr) {
= (Fragment) the @Fragment = (Fragment) the @Fragment
\*/ \*/
Snap.parse = function (svg) { Snap.parse = function (svg) {
var f = glob.doc.createDocumentFragment(), var f,
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; f = new Fragment(svg);
}); div.innerHTML = E;
eve.on("elemental.text", function (text) { return f;
pointer.appendChild(glob.doc.createTextNode(text)); }
}); div.innerHTML = E;
eve.on("elemental./tag", function () { return new Fragment(glob.doc.createDocumentFragment());
pointer = pointer.parentNode;
});
eve.on("elemental.eof", function () {
eve.off("elemental.*");
eve("snap.parsed", f);
});
elemental().parse(svg).end();
return new Fragment(f);
}; };
function Fragment(frag) { function Fragment(frag) {
this.node = frag; this.node = frag;
@ -3130,7 +3127,7 @@ function Paper(w, h) {
height: h, height: h,
version: 1.1, version: 1.1,
width: w, width: w,
xmlns: "http://www.w3.org/2000/svg" xmlns: xmlns
}); });
} }
return res; return res;
@ -3672,7 +3669,7 @@ function gradientRadial(defs, cx, cy, r, fx, fy) {
res; res;
f.appendChild(d); f.appendChild(d);
d.appendChild(svg); d.appendChild(svg);
$(svg, {xmlns: "http://www.w3.org/2000/svg"}); $(svg, {xmlns: xmlns});
res = d.innerHTML; res = d.innerHTML;
f.removeChild(f.firstChild); f.removeChild(f.firstChild);
return res; return res;
@ -3972,395 +3969,448 @@ eve.on("snap.util.attr.text", function (value) {
eve.stop(); eve.stop();
})(-1); })(-1);
// default // default
var availableAttributes = { var // availableAttributes = {
rect: { // rect: {
x: 0, // x: 0,
y: 0, // y: 0,
width: 0, // width: 0,
height: 0, // height: 0,
rx: 0, // rx: 0,
ry: 0, // ry: 0,
"class": 0 // "class": 0
}, // },
circle: { // circle: {
cx: 0, // cx: 0,
cy: 0, // cy: 0,
r: 0, // r: 0,
"class": 0 // "class": 0
}, // },
ellipse: { // ellipse: {
cx: 0, // cx: 0,
cy: 0, // cy: 0,
rx: 0, // rx: 0,
ry: 0, // ry: 0,
"class": 0 // "class": 0
}, // },
line: { // line: {
x1: 0, // x1: 0,
y1: 0, // y1: 0,
x2: 0, // x2: 0,
y2: 0, // y2: 0,
"class": 0 // "class": 0
}, // },
polyline: { // polyline: {
points: "", // points: "",
"class": 0 // "class": 0
}, // },
polygon: { // polygon: {
points: "", // points: "",
"class": 0 // "class": 0
}, // },
text: { // text: {
x: 0, // x: 0,
y: 0, // y: 0,
dx: 0, // dx: 0,
dy: 0, // dy: 0,
rotate: 0, // rotate: 0,
textLength: 0, // textLength: 0,
lengthAdjust: 0, // lengthAdjust: 0,
"class": 0 // "class": 0
}, // },
tspan: { // tspan: {
x: 0, // x: 0,
y: 0, // y: 0,
dx: 0, // dx: 0,
dy: 0, // dy: 0,
rotate: 0, // rotate: 0,
textLength: 0, // textLength: 0,
lengthAdjust: 0, // lengthAdjust: 0,
"class": 0 // "class": 0
}, // },
textPath: { // textPath: {
"xlink:href": 0, // "xlink:href": 0,
startOffset: 0, // startOffset: 0,
method: 0, // method: 0,
spacing: 0, // spacing: 0,
"class": 0 // "class": 0
}, // },
marker: { // marker: {
viewBox: 0, // viewBox: 0,
preserveAspectRatio: 0, // preserveAspectRatio: 0,
refX: 0, // refX: 0,
refY: 0, // refY: 0,
markerUnits: 0, // markerUnits: 0,
markerWidth: 0, // markerWidth: 0,
markerHeight: 0, // markerHeight: 0,
orient: 0, // orient: 0,
"class": 0 // "class": 0
}, // },
use: { // use: {
"class": 0, // externalResourcesRequired: 0,
externalResourcesRequired: 0, // x: 0,
x: 0, // y: 0,
y: 0, // width: 0,
width: 0, // height: 0,
height: 0, // "xlink:href": 0
"xlink:href": 0 // },
}, // linearGradient: {
linearGradient: { // x1: 0,
x1: 0, // y1: 0,
y1: 0, // x2: 0,
x2: 0, // y2: 0,
y2: 0, // gradientUnits: 0,
gradientUnits: 0, // gradientTransform: 0,
gradientTransform: 0, // spreadMethod: 0,
spreadMethod: 0, // "xlink:href": 0,
"xlink:href": 0, // "class": 0
"class": 0 // },
}, // radialGradient: {
radialGradient: { // cx: 0,
cx: 0, // cy: 0,
cy: 0, // r: 0,
r: 0, // fx: 0,
fx: 0, // fy: 0,
fy: 0, // gradientUnits: 0,
gradientUnits: 0, // gradientTransform: 0,
gradientTransform: 0, // spreadMethod: 0,
spreadMethod: 0, // "xlink:href": 0,
"xlink:href": 0, // "class": 0
"class": 0 // },
}, // stop: {
stop: { // offset: 0,
offset: 0, // "class": 0
"class": 0 // },
}, // pattern: {
pattern: { // viewBox: 0,
viewBox: 0, // preserveAspectRatio: 0,
preserveAspectRatio: 0, // x: 0,
x: 0, // y: 0,
y: 0, // width: 0,
width: 0, // height: 0,
height: 0, // patternUnits: 0,
patternUnits: 0, // patternContentUnits: 0,
patternContentUnits: 0, // patternTransform: 0,
patternTransform: 0, // "xlink:href": 0,
"xlink:href": 0, // "class": 0
"class": 0 // },
}, // clipPath: {
clipPath: { // transform: 0,
transform: 0, // clipPathUnits: 0,
clipPathUnits: 0, // "class": 0
"class": 0 // },
}, // mask: {
mask: { // x: 0,
x: 0, // y: 0,
y: 0, // width: 0,
width: 0, // height: 0,
height: 0, // maskUnits: 0,
maskUnits: 0, // maskContentUnits: 0,
maskContentUnits: 0, // "class": 0
"class": 0 // },
}, // image: {
image: { // preserveAspectRatio: 0,
preserveAspectRatio: 0, // transform: 0,
transform: 0, // x: 0,
x: 0, // y: 0,
y: 0, // width: 0,
width: 0, // height: 0,
height: 0, // "xlink:href": 0,
"xlink:href": 0, // "class": 0
"class": 0 // },
}, // path: {
path: { // d: "",
d: "", // "class": 0
"class": 0 // },
}, // g: {
g: { // "class": 0
"class": 0 // },
}, // feDistantLight: {
feDistantLight: { // azimuth: 0,
azimuth: 0, // elevation: 0
elevation: 0 // },
}, // fePointLight: {
fePointLight: { // x: 0,
x: 0, // y: 0,
y: 0, // z: 0
z: 0 // },
}, // feSpotLight: {
feSpotLight: { // x: 0,
x: 0, // y: 0,
y: 0, // z: 0,
z: 0, // pointsAtX: 0,
pointsAtX: 0, // pointsAtY: 0,
pointsAtY: 0, // pointsAtZ: 0,
pointsAtZ: 0, // specularExponent: 0,
specularExponent: 0, // limitingConeAngle: 0
limitingConeAngle: 0 // },
}, // feBlend: {
feBlend: { // height: 0,
height: 0, // result: 0,
result: 0, // width: 0,
width: 0, // x: 0,
x: 0, // y: 0,
y: 0, // style: 0,
"class": 0, // "in": 0,
style: 0, // in2: 0,
"in": 0, // mode: 0
in2: 0, // },
mode: 0 // feColorMatrix: {
}, // height: 0,
feColorMatrix: { // result: 0,
height: 0, // width: 0,
result: 0, // x: 0,
width: 0, // y: 0,
x: 0, // style: 0,
y: 0, // "in": 0,
"class": 0, // type: 0,
style: 0, // values: 0
"in": 0, // },
type: 0, // feComponentTransfer: {
values: 0 // height: 0,
}, // result: 0,
feComponentTransfer: { // width: 0,
height: 0, // x: 0,
result: 0, // y: 0,
width: 0, // style: 0,
x: 0, // "in": 0
y: 0, // },
"class": 0, // feComposite: {
style: 0, // height: 0,
"in": 0 // result: 0,
}, // width: 0,
feComposite: { // x: 0,
height: 0, // y: 0,
result: 0, // style: 0,
width: 0, // "in": 0,
x: 0, // in2: 0,
y: 0, // operator: 0,
"class": 0, // k1: 0,
style: 0, // k2: 0,
"in": 0, // k3: 0,
in2: 0, // k4: 0
operator: 0, // },
k1: 0, // feConvolveMatrix: {
k2: 0, // height: 0,
k3: 0, // result: 0,
k4: 0 // width: 0,
}, // x: 0,
feConvolveMatrix: { // y: 0,
height: 0, // style: 0,
result: 0, // "in": 0,
width: 0, // order: 0,
x: 0, // kernelMatrix: 0,
y: 0, // divisor: 0,
"class": 0, // bias: 0,
style: 0, // targetX: 0,
"in": 0, // targetY: 0,
order: 0, // edgeMode: 0,
kernelMatrix: 0, // kernelUnitLength: 0,
divisor: 0, // preserveAlpha: 0
bias: 0, // },
targetX: 0, // feDiffuseLighting: {
targetY: 0, // height: 0,
edgeMode: 0, // result: 0,
kernelUnitLength: 0, // width: 0,
preserveAlpha: 0 // x: 0,
}, // y: 0,
feDiffuseLighting: { // style: 0,
height: 0, // "in": 0,
result: 0, // surfaceScale: 0,
width: 0, // diffuseConstant: 0,
x: 0, // kernelUnitLength: 0
y: 0, // },
"class": 0, // feDisplacementMap: {
style: 0, // height: 0,
"in": 0, // result: 0,
surfaceScale: 0, // width: 0,
diffuseConstant: 0, // x: 0,
kernelUnitLength: 0 // y: 0,
}, // style: 0,
feDisplacementMap: { // "in": 0,
height: 0, // in2: 0,
result: 0, // scale: 0,
width: 0, // xChannelSelector: 0,
x: 0, // yChannelSelector: 0
y: 0, // },
"class": 0, // feFlood: {
style: 0, // height: 0,
"in": 0, // result: 0,
in2: 0, // width: 0,
scale: 0, // x: 0,
xChannelSelector: 0, // y: 0,
yChannelSelector: 0 // style: 0,
}, // "flood-color": 0,
feFlood: { // "flood-opacity": 0
height: 0, // },
result: 0, // feGaussianBlur: {
width: 0, // height: 0,
x: 0, // result: 0,
y: 0, // width: 0,
"class": 0, // x: 0,
style: 0, // y: 0,
// style: 0,
// "in": 0,
// stdDeviation: 0
// },
// feImage : {
// height: 0,
// result: 0,
// width: 0,
// x: 0,
// y: 0,
// style: 0,
// externalResourcesRequired: 0,
// preserveAspectRatio: 0,
// "xlink:href": 0
// },
// feMerge: {
// height: 0,
// result: 0,
// width: 0,
// x: 0,
// y: 0,
// style: 0
// },
// feMergeNode: {
// "in": 0
// },
// feMorphology: {
// height: 0,
// result: 0,
// width: 0,
// x: 0,
// y: 0,
// style: 0,
// "in": 0,
// operator: 0,
// radius: 0
// },
// feOffset: {
// height: 0,
// result: 0,
// width: 0,
// x: 0,
// y: 0,
// style: 0,
// "in": 0,
// dx: 0,
// dy: 0
// },
// feSpecularLighting: {
// height: 0,
// result: 0,
// width: 0,
// x: 0,
// y: 0,
// style: 0,
// "in": 0,
// surfaceScale: 0,
// specularConstant: 0,
// specularExponent: 0,
// kernelUnitLength: 0
// },
// feTile: {
// height: 0,
// result: 0,
// width: 0,
// x: 0,
// y: 0,
// style: 0,
// "in": 0
// },
// feTurbulence: {
// height: 0,
// result: 0,
// width: 0,
// x: 0,
// y: 0,
// style: 0,
// baseFrequency: 0,
// numOctaves: 0,
// seed: 0,
// stitchTiles: 0,
// type: 0
// }
// },
// attr4all = {
// id: 0,
// "class": 0,
// "xml:space": 0,
// "shape-rendering": 0
// },
cssAttr = {
"alignment-baseline": 0,
"baseline-shift": 0,
"clip": 0,
"clip-path": 0,
"clip-rule": 0,
"color": 0,
"color-interpolation": 0,
"color-interpolation-filters": 0,
"color-profile": 0,
"color-rendering": 0,
"cursor": 0,
"direction": 0,
"display": 0,
"dominant-baseline": 0,
"enable-background": 0,
"fill": 0,
"fill-opacity": 0,
"fill-rule": 0,
"filter": 0,
"flood-color": 0, "flood-color": 0,
"flood-opacity": 0 "flood-opacity": 0,
}, "font": 0,
feGaussianBlur: { "font-family": 0,
height: 0, "font-size": 0,
result: 0, "font-size-adjust": 0,
width: 0, "font-stretch": 0,
x: 0, "font-style": 0,
y: 0, "font-variant": 0,
"class": 0, "font-weight": 0,
style: 0, "glyph-orientation-horizontal": 0,
"in": 0, "glyph-orientation-vertical": 0,
stdDeviation: 0 "image-rendering": 0,
}, "kerning": 0,
feImage : { "letter-spacing": 0,
height: 0, "lighting-color": 0,
result: 0, "marker": 0,
width: 0, "marker-end": 0,
x: 0, "marker-mid": 0,
y: 0, "marker-start": 0,
"class": 0, "mask": 0,
style: 0, "opacity": 0,
externalResourcesRequired: 0, "overflow": 0,
preserveAspectRatio: 0, "pointer-events": 0,
"xlink:href": 0 "shape-rendering": 0,
}, "stop-color": 0,
feMerge: { "stop-opacity": 0,
height: 0, "stroke": 0,
result: 0, "stroke-dasharray": 0,
width: 0, "stroke-dashoffset": 0,
x: 0, "stroke-linecap": 0,
y: 0, "stroke-linejoin": 0,
"class": 0, "stroke-miterlimit": 0,
style: 0 "stroke-opacity": 0,
}, "stroke-width": 0,
feMergeNode: { "text-anchor": 0,
"in": 0 "text-decoration": 0,
}, "text-rendering": 0,
feMorphology: { "unicode-bidi": 0,
height: 0, "visibility": 0,
result: 0, "word-spacing": 0,
width: 0, "writing-mode": 0
x: 0,
y: 0,
"class": 0,
style: 0,
"in": 0,
operator: 0,
radius: 0
},
feOffset: {
height: 0,
result: 0,
width: 0,
x: 0,
y: 0,
"class": 0,
style: 0,
"in": 0,
dx: 0,
dy: 0
},
feSpecularLighting: {
height: 0,
result: 0,
width: 0,
x: 0,
y: 0,
"class": 0,
style: 0,
"in": 0,
surfaceScale: 0,
specularConstant: 0,
specularExponent: 0,
kernelUnitLength: 0
},
feTile: {
height: 0,
result: 0,
width: 0,
x: 0,
y: 0,
"class": 0,
style: 0,
"in": 0
},
feTurbulence: {
height: 0,
result: 0,
width: 0,
x: 0,
y: 0,
"class": 0,
style: 0,
baseFrequency: 0,
numOctaves: 0,
seed: 0,
stitchTiles: 0,
type: 0
}
};
availableAttributes.feFuncR = availableAttributes.feFuncG = availableAttributes.feFuncB = availableAttributes.feFuncA = {
type: 0,
tableValues: 0,
slope: 0,
intercept: 0,
amplitude: 0,
exponent: 0,
offset: 0
}; };
// availableAttributes.feFuncR = availableAttributes.feFuncG = availableAttributes.feFuncB = availableAttributes.feFuncA = {
// type: 0,
// tableValues: 0,
// slope: 0,
// intercept: 0,
// amplitude: 0,
// exponent: 0,
// offset: 0
// };
eve.on("snap.util.attr", function (value) { eve.on("snap.util.attr", function (value) {
var att = eve.nt(), var att = eve.nt(),
attr = {}; attr = {};
@ -4368,12 +4418,20 @@ eve.on("snap.util.attr", function (value) {
attr[att] = value; attr[att] = value;
var style = att.replace(/-(\w)/gi, function (all, letter) { var style = att.replace(/-(\w)/gi, function (all, letter) {
return letter.toUpperCase(); return letter.toUpperCase();
}),
css = att.replace(/[A-Z]/g, function (letter) {
return "-" + letter.toLowerCase();
}); });
if (availableAttributes[has](this.type) && (availableAttributes[this.type][has](att) || att == "id")) { if (cssAttr[has](css)) {
$(this.node, attr);
} else {
this.node.style[style] = value == null ? E : value; this.node.style[style] = value == null ? E : value;
} else {
$(this.node, attr);
} }
// if (availableAttributes[has](this.type) && (availableAttributes[this.type][has](att) || att == "id")) {
// $(this.node, attr);
// } else {
// this.node.style[style] = value == null ? E : value;
// }
}); });
eve.on("snap.util.getattr.transform", function () { eve.on("snap.util.getattr.transform", function () {
eve.stop(); eve.stop();
@ -4477,10 +4535,13 @@ eve.on("snap.util.getattr.path", function () {
eve.on("snap.util.getattr", function () { eve.on("snap.util.getattr", function () {
var att = eve.nt(); var att = eve.nt();
att = att.substring(att.lastIndexOf(".") + 1); att = att.substring(att.lastIndexOf(".") + 1);
if (availableAttributes[has](this.type) && availableAttributes[this.type][has](att)) { var css = att.replace(/[A-Z]/g, function (letter) {
return this.node.getAttribute(att); return "-" + letter.toLowerCase();
});
if (cssAttr[has](css)) {
return glob.doc.defaultView.getComputedStyle(this.node, null).getPropertyValue(css);
} else { } else {
return glob.doc.defaultView.getComputedStyle(this.node, null).getPropertyValue(att); return $(this.node, att);
} }
}); });
Snap.plugin = function (f) { Snap.plugin = function (f) {

View File

@ -13,8 +13,7 @@
// limitations under the License. // limitations under the License.
var Snap = (function() { var Snap = (function() {
Snap.version = "0.1.0"; Snap.version = "0.1.1";
// SIERRA: this method appears to be missing from HTML output
/*\ /*\
* Snap * Snap
[ method ] [ method ]
@ -87,6 +86,7 @@ var has = "hasOwnProperty",
return idprefix + (idgen++).toString(36); return idprefix + (idgen++).toString(36);
}, },
xlink = "http://www.w3.org/1999/xlink", xlink = "http://www.w3.org/1999/xlink",
xmlns = "http://www.w3.org/2000/svg",
hub = {}; hub = {};
function $(el, attr) { function $(el, attr) {
@ -98,6 +98,9 @@ function $(el, attr) {
if (attr.substring(0, 6) == "xlink:") { if (attr.substring(0, 6) == "xlink:") {
return el.getAttributeNS(xlink, attr.substring(6)); return el.getAttributeNS(xlink, attr.substring(6));
} }
if (attr.substring(0, 4) == "xml:") {
return el.getAttributeNS(xmlns, attr.substring(4));
}
return el.getAttribute(attr); return el.getAttribute(attr);
} }
for (var key in attr) if (attr[has](key)) { for (var key in attr) if (attr[has](key)) {
@ -105,6 +108,8 @@ function $(el, attr) {
if (val) { if (val) {
if (key.substring(0, 6) == "xlink:") { if (key.substring(0, 6) == "xlink:") {
el.setAttributeNS(xlink, key.substring(6), val); el.setAttributeNS(xlink, key.substring(6), val);
} else if (key.substring(0, 4) == "xml:") {
el.setAttributeNS(xmlns, key.substring(4), val);
} else { } else {
el.setAttribute(key, val); el.setAttribute(key, val);
} }
@ -113,7 +118,7 @@ function $(el, attr) {
} }
} }
} else { } else {
el = glob.doc.createElementNS("http://www.w3.org/2000/svg", el); el = glob.doc.createElementNS(xmlns, el);
// el.style && (el.style.webkitTapHighlightColor = "rgba(0,0,0,0)"); // el.style && (el.style.webkitTapHighlightColor = "rgba(0,0,0,0)");
} }
return el; return el;
@ -2279,26 +2284,18 @@ function arrayFirstValue(arr) {
= (Fragment) the @Fragment = (Fragment) the @Fragment
\*/ \*/
Snap.parse = function (svg) { Snap.parse = function (svg) {
var f = glob.doc.createDocumentFragment(), var f,
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; f = new Fragment(svg);
}); div.innerHTML = E;
eve.on("elemental.text", function (text) { return f;
pointer.appendChild(glob.doc.createTextNode(text)); }
}); div.innerHTML = E;
eve.on("elemental./tag", function () { return new Fragment(glob.doc.createDocumentFragment());
pointer = pointer.parentNode;
});
eve.on("elemental.eof", function () {
eve.off("elemental.*");
eve("snap.parsed", f);
});
elemental().parse(svg).end();
return new Fragment(f);
}; };
function Fragment(frag) { function Fragment(frag) {
this.node = frag; this.node = frag;
@ -2384,7 +2381,7 @@ function Paper(w, h) {
height: h, height: h,
version: 1.1, version: 1.1,
width: w, width: w,
xmlns: "http://www.w3.org/2000/svg" xmlns: xmlns
}); });
} }
return res; return res;
@ -2926,7 +2923,7 @@ function gradientRadial(defs, cx, cy, r, fx, fy) {
res; res;
f.appendChild(d); f.appendChild(d);
d.appendChild(svg); d.appendChild(svg);
$(svg, {xmlns: "http://www.w3.org/2000/svg"}); $(svg, {xmlns: xmlns});
res = d.innerHTML; res = d.innerHTML;
f.removeChild(f.firstChild); f.removeChild(f.firstChild);
return res; return res;
@ -3226,395 +3223,70 @@ eve.on("snap.util.attr.text", function (value) {
eve.stop(); eve.stop();
})(-1); })(-1);
// default // default
var availableAttributes = { var cssAttr = {
rect: { "alignment-baseline": 0,
x: 0, "baseline-shift": 0,
y: 0, "clip": 0,
width: 0, "clip-path": 0,
height: 0, "clip-rule": 0,
rx: 0, "color": 0,
ry: 0, "color-interpolation": 0,
"class": 0 "color-interpolation-filters": 0,
}, "color-profile": 0,
circle: { "color-rendering": 0,
cx: 0, "cursor": 0,
cy: 0, "direction": 0,
r: 0, "display": 0,
"class": 0 "dominant-baseline": 0,
}, "enable-background": 0,
ellipse: { "fill": 0,
cx: 0, "fill-opacity": 0,
cy: 0, "fill-rule": 0,
rx: 0, "filter": 0,
ry: 0,
"class": 0
},
line: {
x1: 0,
y1: 0,
x2: 0,
y2: 0,
"class": 0
},
polyline: {
points: "",
"class": 0
},
polygon: {
points: "",
"class": 0
},
text: {
x: 0,
y: 0,
dx: 0,
dy: 0,
rotate: 0,
textLength: 0,
lengthAdjust: 0,
"class": 0
},
tspan: {
x: 0,
y: 0,
dx: 0,
dy: 0,
rotate: 0,
textLength: 0,
lengthAdjust: 0,
"class": 0
},
textPath: {
"xlink:href": 0,
startOffset: 0,
method: 0,
spacing: 0,
"class": 0
},
marker: {
viewBox: 0,
preserveAspectRatio: 0,
refX: 0,
refY: 0,
markerUnits: 0,
markerWidth: 0,
markerHeight: 0,
orient: 0,
"class": 0
},
use: {
"class": 0,
externalResourcesRequired: 0,
x: 0,
y: 0,
width: 0,
height: 0,
"xlink:href": 0
},
linearGradient: {
x1: 0,
y1: 0,
x2: 0,
y2: 0,
gradientUnits: 0,
gradientTransform: 0,
spreadMethod: 0,
"xlink:href": 0,
"class": 0
},
radialGradient: {
cx: 0,
cy: 0,
r: 0,
fx: 0,
fy: 0,
gradientUnits: 0,
gradientTransform: 0,
spreadMethod: 0,
"xlink:href": 0,
"class": 0
},
stop: {
offset: 0,
"class": 0
},
pattern: {
viewBox: 0,
preserveAspectRatio: 0,
x: 0,
y: 0,
width: 0,
height: 0,
patternUnits: 0,
patternContentUnits: 0,
patternTransform: 0,
"xlink:href": 0,
"class": 0
},
clipPath: {
transform: 0,
clipPathUnits: 0,
"class": 0
},
mask: {
x: 0,
y: 0,
width: 0,
height: 0,
maskUnits: 0,
maskContentUnits: 0,
"class": 0
},
image: {
preserveAspectRatio: 0,
transform: 0,
x: 0,
y: 0,
width: 0,
height: 0,
"xlink:href": 0,
"class": 0
},
path: {
d: "",
"class": 0
},
g: {
"class": 0
},
feDistantLight: {
azimuth: 0,
elevation: 0
},
fePointLight: {
x: 0,
y: 0,
z: 0
},
feSpotLight: {
x: 0,
y: 0,
z: 0,
pointsAtX: 0,
pointsAtY: 0,
pointsAtZ: 0,
specularExponent: 0,
limitingConeAngle: 0
},
feBlend: {
height: 0,
result: 0,
width: 0,
x: 0,
y: 0,
"class": 0,
style: 0,
"in": 0,
in2: 0,
mode: 0
},
feColorMatrix: {
height: 0,
result: 0,
width: 0,
x: 0,
y: 0,
"class": 0,
style: 0,
"in": 0,
type: 0,
values: 0
},
feComponentTransfer: {
height: 0,
result: 0,
width: 0,
x: 0,
y: 0,
"class": 0,
style: 0,
"in": 0
},
feComposite: {
height: 0,
result: 0,
width: 0,
x: 0,
y: 0,
"class": 0,
style: 0,
"in": 0,
in2: 0,
operator: 0,
k1: 0,
k2: 0,
k3: 0,
k4: 0
},
feConvolveMatrix: {
height: 0,
result: 0,
width: 0,
x: 0,
y: 0,
"class": 0,
style: 0,
"in": 0,
order: 0,
kernelMatrix: 0,
divisor: 0,
bias: 0,
targetX: 0,
targetY: 0,
edgeMode: 0,
kernelUnitLength: 0,
preserveAlpha: 0
},
feDiffuseLighting: {
height: 0,
result: 0,
width: 0,
x: 0,
y: 0,
"class": 0,
style: 0,
"in": 0,
surfaceScale: 0,
diffuseConstant: 0,
kernelUnitLength: 0
},
feDisplacementMap: {
height: 0,
result: 0,
width: 0,
x: 0,
y: 0,
"class": 0,
style: 0,
"in": 0,
in2: 0,
scale: 0,
xChannelSelector: 0,
yChannelSelector: 0
},
feFlood: {
height: 0,
result: 0,
width: 0,
x: 0,
y: 0,
"class": 0,
style: 0,
"flood-color": 0, "flood-color": 0,
"flood-opacity": 0 "flood-opacity": 0,
}, "font": 0,
feGaussianBlur: { "font-family": 0,
height: 0, "font-size": 0,
result: 0, "font-size-adjust": 0,
width: 0, "font-stretch": 0,
x: 0, "font-style": 0,
y: 0, "font-variant": 0,
"class": 0, "font-weight": 0,
style: 0, "glyph-orientation-horizontal": 0,
"in": 0, "glyph-orientation-vertical": 0,
stdDeviation: 0 "image-rendering": 0,
}, "kerning": 0,
feImage : { "letter-spacing": 0,
height: 0, "lighting-color": 0,
result: 0, "marker": 0,
width: 0, "marker-end": 0,
x: 0, "marker-mid": 0,
y: 0, "marker-start": 0,
"class": 0, "mask": 0,
style: 0, "opacity": 0,
externalResourcesRequired: 0, "overflow": 0,
preserveAspectRatio: 0, "pointer-events": 0,
"xlink:href": 0 "shape-rendering": 0,
}, "stop-color": 0,
feMerge: { "stop-opacity": 0,
height: 0, "stroke": 0,
result: 0, "stroke-dasharray": 0,
width: 0, "stroke-dashoffset": 0,
x: 0, "stroke-linecap": 0,
y: 0, "stroke-linejoin": 0,
"class": 0, "stroke-miterlimit": 0,
style: 0 "stroke-opacity": 0,
}, "stroke-width": 0,
feMergeNode: { "text-anchor": 0,
"in": 0 "text-decoration": 0,
}, "text-rendering": 0,
feMorphology: { "unicode-bidi": 0,
height: 0, "visibility": 0,
result: 0, "word-spacing": 0,
width: 0, "writing-mode": 0
x: 0,
y: 0,
"class": 0,
style: 0,
"in": 0,
operator: 0,
radius: 0
},
feOffset: {
height: 0,
result: 0,
width: 0,
x: 0,
y: 0,
"class": 0,
style: 0,
"in": 0,
dx: 0,
dy: 0
},
feSpecularLighting: {
height: 0,
result: 0,
width: 0,
x: 0,
y: 0,
"class": 0,
style: 0,
"in": 0,
surfaceScale: 0,
specularConstant: 0,
specularExponent: 0,
kernelUnitLength: 0
},
feTile: {
height: 0,
result: 0,
width: 0,
x: 0,
y: 0,
"class": 0,
style: 0,
"in": 0
},
feTurbulence: {
height: 0,
result: 0,
width: 0,
x: 0,
y: 0,
"class": 0,
style: 0,
baseFrequency: 0,
numOctaves: 0,
seed: 0,
stitchTiles: 0,
type: 0
}
};
availableAttributes.feFuncR = availableAttributes.feFuncG = availableAttributes.feFuncB = availableAttributes.feFuncA = {
type: 0,
tableValues: 0,
slope: 0,
intercept: 0,
amplitude: 0,
exponent: 0,
offset: 0
}; };
eve.on("snap.util.attr", function (value) { eve.on("snap.util.attr", function (value) {
var att = eve.nt(), var att = eve.nt(),
attr = {}; attr = {};
@ -3622,11 +3294,14 @@ eve.on("snap.util.attr", function (value) {
attr[att] = value; attr[att] = value;
var style = att.replace(/-(\w)/gi, function (all, letter) { var style = att.replace(/-(\w)/gi, function (all, letter) {
return letter.toUpperCase(); return letter.toUpperCase();
}),
css = att.replace(/[A-Z]/g, function (letter) {
return "-" + letter.toLowerCase();
}); });
if (availableAttributes[has](this.type) && (availableAttributes[this.type][has](att) || att == "id")) { if (cssAttr[has](css)) {
$(this.node, attr);
} else {
this.node.style[style] = value == null ? E : value; this.node.style[style] = value == null ? E : value;
} else {
$(this.node, attr);
} }
}); });
eve.on("snap.util.getattr.transform", function () { eve.on("snap.util.getattr.transform", function () {
@ -3731,10 +3406,13 @@ eve.on("snap.util.getattr.path", function () {
eve.on("snap.util.getattr", function () { eve.on("snap.util.getattr", function () {
var att = eve.nt(); var att = eve.nt();
att = att.substring(att.lastIndexOf(".") + 1); att = att.substring(att.lastIndexOf(".") + 1);
if (availableAttributes[has](this.type) && availableAttributes[this.type][has](att)) { var css = att.replace(/[A-Z]/g, function (letter) {
return this.node.getAttribute(att); return "-" + letter.toLowerCase();
});
if (cssAttr[has](css)) {
return glob.doc.defaultView.getComputedStyle(this.node, null).getPropertyValue(css);
} else { } else {
return glob.doc.defaultView.getComputedStyle(this.node, null).getPropertyValue(att); return $(this.node, att);
} }
}); });
Snap.plugin = function (f) { Snap.plugin = function (f) {

View File

@ -8,7 +8,4 @@ describe("System check", function () {
it("mina exists", function () { it("mina exists", function () {
expect(mina).to.be.a("function"); expect(mina).to.be.a("function");
}); });
it("elemental exists", function () {
expect(elemental).to.be.a("function");
});
}); });