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

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

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

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