Ai
2 Star 0 Fork 0

mirrors_WebReflection/html-class

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
html-class.js 1.33 KB
一键复制 编辑 原始数据 按行查看 历史
Andrea Giammarchi 提交于 2016-08-17 01:58 +08:00 . universal version fixed
var htmlClass = (function (info) {'use strict';
// (C) Andrea Giammarchi - @WebReflection - MIT Style
var
catchClass = /^[A-Z]+[a-z]/,
filterBy = function (re) {
var arr = [], tag;
for (tag in register) {
if (re.test(tag)) arr.push(tag);
}
return arr;
},
add = function (Class, tag) {
tag = tag.toLowerCase();
if (!(tag in register)) {
register[Class] = (register[Class] || []).concat(tag);
register[tag] = (register[tag.toUpperCase()] = Class);
}
},
register = (Object.create || Object)(null),
htmlClass = {},
i, section, tags, Class
;
for (section in info) {
for (Class in info[section]) {
tags = info[section][Class];
register[Class] = tags;
for (i = 0; i < tags.length; i++) {
register[tags[i].toLowerCase()] =
register[tags[i].toUpperCase()] = Class;
}
}
}
htmlClass.get = function get(tagOrClass) {
return typeof tagOrClass === 'string' ?
(register[tagOrClass] || (catchClass.test(tagOrClass) ? [] : '')) :
filterBy(tagOrClass);
};
htmlClass.set = function set(tag, Class) {
return (catchClass.test(tag) ?
add(tag, Class) :
add(Class, tag)
), htmlClass;
};
return htmlClass;
}(/* require:info.json */));
try { module.exports = htmlClass; } catch(meh) {}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/mirrors_WebReflection/html-class.git
git@gitee.com:mirrors_WebReflection/html-class.git
mirrors_WebReflection
html-class
html-class
master

搜索帮助