summaryrefslogtreecommitdiffstats
path: root/src/use.js
blob: d50799815d32b4890b0e7d9a10faf6861d8fc337 (plain)
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
SVG.Use = function() {
  this.constructor.call(this, SVG.create('use'))
}

// Inherit from SVG.Shape
SVG.Use.prototype = new SVG.Element

//
SVG.extend(SVG.Use, {
  // Use element as a reference
  element: function(element) {
    /* store target element */
    this.target = element

    /* set lined element */
    return this.attr('xlink:href', '#' + element, SVG.xlink)
  }
  
})

//
SVG.extend(SVG.Container, {
  // Create a use element
  use: function(element) {
    return this.put(new SVG.Use).element(element)
  }

})