blob: 7921461bc8fd2a6f8bc68a965b1ebd3b55c52edc (
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
|
import { nodeOrNew, register, wrapWithAttrCheck } from '../utils/adopter.js'
import { registerMethods } from '../utils/methods.js'
import { xlink } from '../modules/core/namespaces.js'
import Shape from './Shape.js'
export default class Use extends Shape {
constructor (node) {
super(nodeOrNew('use', node), node)
}
// Use element as a reference
element (element, file) {
// Set lined element
return this.attr('href', (file || '') + '#' + element, xlink)
}
}
registerMethods({
Container: {
// Create a use element
use: wrapWithAttrCheck(function (element, file) {
return this.put(new Use()).element(element, file)
})
}
})
register(Use)
|