-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathsvg.coffee
57 lines (53 loc) · 1 KB
/
svg.coffee
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
createSvgElement = (options, {name, children}) ->
el = document.createElementNS("http://www.w3.org/2000/svg",name)
if name == "svg"
el.setAttributeNS("http://www.w3.org/2000/xmlns/", "xmlns:xlink", "http://www.w3.org/1999/xlink")
return el: el, options: options, children: children
svgTags = [
"svg"
"animate"
"circle"
"clippath"
"cursor"
"defs"
"desc"
"ellipse"
"filter"
"fontFace"
"foreignObject"
"g"
"glyph"
"image"
"line"
"marker"
"mask"
"missingGlyph"
"path"
"pattern"
"polygon"
"polyline"
"rect"
"switch"
"symbol"
"text"
"textpath"
"tspan"
"use"
"view"
]
lookup = {}
for name in svgTags
lookup[name] = createSvgElement
module.exports =
_name: "svg"
_v: 1
_elLookup: lookup
mixins: [
require "./structure"
]
test module.exports, {
structure: template 1, """<svg test></svg>"""
}, (el) ->
it "should have svg element", ->
el.should.contain "svg[test]"
el.children[0].namespaceURI.should.equal "http://www.w3.org/2000/svg"