Remove dependency on Mousetrap

This commit is contained in:
Frederic Guillot
2016-12-30 20:14:36 -05:00
parent e1344e3e44
commit ff79ec72c1
20 changed files with 348 additions and 202 deletions

View File

@@ -4,10 +4,12 @@ KB.dom = function (tag) {
var element = typeof tag === 'string' ? document.createElement(tag) : tag;
this.attr = function (attribute, value) {
if (value !== null) {
if (value !== null && typeof value !== 'undefined') {
element.setAttribute(attribute, value);
return this;
} else {
return element.getAttribute(attribute);
}
return this;
};
this.data = function (attribute, value) {
@@ -175,3 +177,15 @@ KB.find = function (selector) {
return null;
};
KB.exists = function (selector) {
return !!document.querySelector(selector);
};
KB.focus = function (selector) {
var element = document.querySelector(selector);
if (element) {
return element.focus();
}
};