-
Notifications
You must be signed in to change notification settings - Fork 0
/
remove.js
38 lines (32 loc) · 945 Bytes
/
remove.js
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
import isString from './utils/isString'
import getSymbol from './getSymbol'
import SYMBOLS from './symbols'
/**
* 通过名称移除图标集中的 symbol
* ========================================================================
* @method remove
* @param {String} name - 图标名称
* @param {String} [iconSet] - (可选)图标集名称,默认值:icon
* @return {boolean}
*/
const remove = (name, iconSet = 'icon') => {
const $icons = document.querySelector('#ijs-icons')
const target = getSymbol(name, iconSet)
let index = -1
let $symbol
let selector
if (!isString(name)) {
return false
}
index = SYMBOLS.indexOf(target)
/* istanbul ignore else */
if (index > -1) {
SYMBOLS.splice(index, 1)
}
if ($icons) {
selector = `#${iconSet === 'icon' ? 'icon' : iconSet + '-icon'}-${name}`
$symbol = $icons.querySelector(selector)
$icons.removeChild($symbol)
}
}
export default remove