More independent.
This commit is contained in:
@@ -49,3 +49,27 @@ exports.css = function (element, styleNameOrObject, styleValue) {
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
exports.matches = function (element, query) {
|
||||
if (typeof element.matches !== 'undefined') {
|
||||
return element.matches(query);
|
||||
} else {
|
||||
if (typeof element.matchesSelector !== 'undefined') {
|
||||
return element.matchesSelector(query);
|
||||
} else if (element.webkitMatchesSelector !== 'undefined') {
|
||||
return element.webkitMatchesSelector(query);
|
||||
} else if (element.mozMatchesSelector !== 'undefined') {
|
||||
return element.mozMatchesSelector(query);
|
||||
} else if (element.msMatchesSelector !== 'undefined') {
|
||||
return element.msMatchesSelector(query);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
exports.remove = function (element) {
|
||||
if (typeof element.remove !== 'undefined') {
|
||||
element.remove();
|
||||
} else {
|
||||
element.parentNode.removeChild(element);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -3,6 +3,8 @@
|
||||
*/
|
||||
'use strict';
|
||||
|
||||
var d = require('./dom');
|
||||
|
||||
exports.toInt = function (x) {
|
||||
if (typeof x === 'string') {
|
||||
return parseInt(x, 10);
|
||||
@@ -34,3 +36,10 @@ exports.extend = function (original, source) {
|
||||
}
|
||||
return result;
|
||||
};
|
||||
|
||||
exports.isEditable = function (el) {
|
||||
return d.matches(el, "input,[contenteditable]") ||
|
||||
d.matches(el, "select,[contenteditable]") ||
|
||||
d.matches(el, "textarea,[contenteditable]") ||
|
||||
d.matches(el, "button,[contenteditable]");
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user