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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
import _extends from 'babel-runtime/helpers/extends';
import _objectWithoutProperties from 'babel-runtime/helpers/objectWithoutProperties';
import Icon from './index';
var customCache = new Set();
export default function create(options) {
var scriptUrl = options.scriptUrl;
/**
* DOM API required.
* Make sure in browser environment.
* The Custom Icon will create a <script/>
* that loads SVG symbols and insert the SVG Element into the document body.
*/
if (typeof document !== 'undefined' && typeof window !== 'undefined' && typeof document.createElement === 'function' && typeof scriptUrl === 'string' && scriptUrl.length && !customCache.has(scriptUrl)) {
var script = document.createElement('script');
script.setAttribute('src', scriptUrl);
script.setAttribute('data-namespace', scriptUrl);
customCache.add(scriptUrl);
document.body.appendChild(script);
}
var Iconfont = {
functional: true,
name: 'AIconfont',
props: Icon.props,
render: function render(h, context) {
var props = context.props,
slots = context.slots,
listeners = context.listeners,
data = context.data;
var type = props.type,
restProps = _objectWithoutProperties(props, ['type']);
var slotsMap = slots();
var children = slotsMap['default'];
// component > children > type
var content = null;
if (type) {
content = h('use', { attrs: { 'xlink:href': '#' + type } });
}
if (children) {
content = children;
}
return h(
Icon,
_extends({}, data, { props: restProps, on: listeners }),
[content]
);
}
};
return Iconfont;
}