| 1 | "use strict"; |
| 2 | var Element = require('./Element'); |
| 3 | var defineElement = require('./defineElement'); |
| 4 | var utils = require('./utils'); |
| 5 | var CSSStyleDeclaration = require('./CSSStyleDeclaration'); |
| 6 | |
| 7 | var svgElements = exports.elements = {}; |
| 8 | var svgNameToImpl = Object.create(null); |
| 9 | |
| 10 | exports.createElement = function(doc, localName, prefix) { |
| 11 | var impl = svgNameToImpl[localName] || SVGElement; |
| 12 | return new impl(doc, localName, prefix); |
| 13 | }; |
| 14 | |
| 15 | function define(spec) { |
| 16 | return defineElement(spec, SVGElement, svgElements, svgNameToImpl); |
| 17 | } |
| 18 | |
| 19 | var SVGElement = define({ |
| 20 | superclass: Element, |
| 21 | name: 'SVGElement', |
| 22 | ctor: function SVGElement(doc, localName, prefix) { |
| 23 | Element.call(this, doc, localName, utils.NAMESPACE.SVG, prefix); |
| 24 | }, |
| 25 | props: { |
| 26 | style: { get: function() { |
| 27 | if (!this._style) |
| 28 | this._style = new CSSStyleDeclaration(this); |
| 29 | return this._style; |
| 30 | }} |
| 31 | } |
| 32 | }); |
| 33 | |
| 34 | define({ |
| 35 | name: 'SVGSVGElement', |
| 36 | ctor: function SVGSVGElement(doc, localName, prefix) { |
| 37 | SVGElement.call(this, doc, localName, prefix); |
| 38 | }, |
| 39 | tag: 'svg', |
| 40 | props: { |
| 41 | createSVGRect: { value: function () { |
| 42 | return exports.createElement(this.ownerDocument, 'rect', null); |
| 43 | } } |
| 44 | } |
| 45 | }); |
| 46 | |
| 47 | define({ |
| 48 | tags: [ |
| 49 | 'a', 'altGlyph', 'altGlyphDef', 'altGlyphItem', 'animate', 'animateColor', 'animateMotion', 'animateTransform', |
| 50 | 'circle', 'clipPath', 'color-profile', 'cursor', 'defs', 'desc', 'ellipse', 'feBlend', 'feColorMatrix', |
| 51 | 'feComponentTransfer', 'feComposite', 'feConvolveMatrix', 'feDiffuseLighting', 'feDisplacementMap', 'feDistantLight', |
| 52 | 'feFlood', 'feFuncA', 'feFuncB', 'feFuncG', 'feFuncR', 'feGaussianBlur', 'feImage', 'feMerge', 'feMergeNode', |
| 53 | 'feMorphology', 'feOffset', 'fePointLight', 'feSpecularLighting', 'feSpotLight', 'feTile', 'feTurbulence', 'filter', |
| 54 | 'font', 'font-face', 'font-face-format', 'font-face-name', 'font-face-src', 'font-face-uri', 'foreignObject', 'g', |
| 55 | 'glyph', 'glyphRef', 'hkern', 'image', 'line', 'linearGradient', 'marker', 'mask', 'metadata', 'missing-glyph', |
| 56 | 'mpath', 'path', 'pattern', 'polygon', 'polyline', 'radialGradient', 'rect', 'script', 'set', 'stop', 'style', |
| 57 | 'switch', 'symbol', 'text', 'textPath', 'title', 'tref', 'tspan', 'use', 'view', 'vkern' |
| 58 | ] |
| 59 | }); |