feat(render): add auto header

This commit is contained in:
qingwei.li 2017-02-18 21:59:19 +08:00 • committed by cinwell.li
commit b7768b1b3c
6 changed files with 50 additions and 26 deletions

View file

@ -52,6 +52,10 @@ export function appendTo (target, el) {
return target.appendChild(el)
}
export function before (target, el) {
return target.insertBefore(el, target.children[0])
}
export function on (el, type, handler) {
isFn(type)
? window.addEventListener(el, type)
@ -72,5 +76,5 @@ export const off = function on (el, type, handler) {
* toggleClass(el, 'add', 'active') => el.classList.add('active')
*/
export function toggleClass (el, type, val) {
el.classList[val ? type : 'toggle'](val || type)
el && el.classList[val ? type : 'toggle'](val || type)
}