aboutsummaryrefslogtreecommitdiffstats
path: root/src/use.js
blob: 9bea70c8513cc9d9d28d5e0056f63b8a9145bca8 (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
SVG.Use = SVG.invent({
  // Initialize node
  create: 'use'

  // Inherit from
, inherit: SVG.Shape

  // Add class methods
, extend: {
    // Use element as a reference
    element: function(element, file) {
      /* store target element */
      this.target = element

      /* set lined element */
      return this.attr('href', (file || '') + '#' + element, SVG.xlink)
    }
  }
  
  // Add parent method
, construct: {
    // Create a use element
    use: function(element, file) {
      return this.put(new SVG.Use).element(element, file)
    }
  }
})