diff options
Diffstat (limited to 'src/css.js')
-rw-r--r-- | src/css.js | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/src/css.js b/src/css.js new file mode 100644 index 0000000..b5f2702 --- /dev/null +++ b/src/css.js @@ -0,0 +1,24 @@ +SVG.extend(SVG.Element, { + // Dynamic style generator + style: function(s, v) { + if (arguments.length == 0) { + // get full style + return this.node.style.cssText || '' + + } else if (arguments.length < 2) { + // apply every style individually if an object is passed + if (typeof s == 'object') { + for (v in s) this.style(v, s[v]) + + } else { + // act as a getter if the first and only argument is not an object + return this.node.style[camelCase(s)] + } + + } else { + this.node.style[camelCase(s)] = v === null || SVG.regex.isBlank.test(v) ? '' : v + } + + return this + } +}) |