summaryrefslogtreecommitdiffstats
path: root/src/Use.js
blob: 9cf1711b8a9ab393b6a52611b7dd2dd3efc9ed59 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
import {Shape, Container} from './classes.js'
import {xlink} from './namespaces.js'

export default class Use extends Shape {
  constructor (node) {
    super(nodeOrNew('use', node))
  }

  // Use element as a reference
  element (element, file) {
    // Set lined element
    return this.attr('href', (file || '') + '#' + element, xlink)
  }
}

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