This is an automated email from the ASF dual-hosted git repository.
jeb pushed a commit to branch master
in repository
https://gitbox.apache.org/repos/asf/sling-org-apache-sling-app-cms.git
The following commit(s) were added to refs/heads/master by this push:
new a60c9a5 IE11 support completed for nomnom
a60c9a5 is described below
commit a60c9a509cf5019fc254c297dee21b1f1cc0f37f
Author: JE Bailey <[email protected]>
AuthorDate: Fri Oct 19 12:44:51 2018 -0400
IE11 support completed for nomnom
---
ui/src/main/frontend/src/js/nomnom.js | 43 +++++++++++++++++++----------------
1 file changed, 24 insertions(+), 19 deletions(-)
diff --git a/ui/src/main/frontend/src/js/nomnom.js
b/ui/src/main/frontend/src/js/nomnom.js
index 70804d1..8a032bf 100644
--- a/ui/src/main/frontend/src/js/nomnom.js
+++ b/ui/src/main/frontend/src/js/nomnom.js
@@ -19,26 +19,32 @@
/* eslint-env es6, browser */
(function(nomnom) {
+ if (!Element.prototype.matches) {
+ Element.prototype.matches = Element.prototype.msMatchesSelector;
+ }
+
+ if (typeof NodeList.prototype.forEach !== "function" && typeof
Array.prototype.forEach === "function") {
+ NodeList.prototype.forEach = Array.prototype.forEach;
+ }
+
+ var tagSelectors = {};
+ var debug = false;
+ var elementMap = new WeakMap();
+
// public
nomnom.decorate = function(selector, config) {
- if (debug) {
+ if (debug) {
console.log("storing selector" + selector);
}
tagSelectors[selector] = config;
- document.querySelectorAll(selector).forEach(function(node) {
- wrap(node, config);
- });
+ let foundItems = document.querySelectorAll(selector);
+ if (foundItems) {
+ foundItems.forEach(function(node) {
+ wrap(node, config);
+ });
+ }
};
- nomnom.enhancecalm = function(event){
- event.preventDefault();
- event.stopPropagation();
- }
-
- var tagSelectors = {};
- var debug = false;
- var elementMap = new WeakMap();
-
new MutationObserver(function(mutations) {
mutations.forEach(function(mutation) {
mutation.addedNodes.forEach(function(node) {
@@ -56,10 +62,8 @@
if (debug) {
console.log("decorating element " + node + node.name);
}
- var configSet;
- if (elementMap.has(node)) {
- configSet = elementMap.get(node);
- } else {
+ var configSet = elementMap.get(node);
+ if (!configSet) {
configSet = new Set();
elementMap.set(node, configSet);
}
@@ -142,7 +146,8 @@
};
var checkAll = function(node) {
- var checkSet = new Set([node]);
+ var checkSet = new Set();
+ checkSet.add(node);
checkSet.forEach(function(element){
if (element.querySelectorAll) {
check(element);
@@ -156,7 +161,7 @@
checkSet.delete(element);
});
}
-
+
var check = function(node) {
for ( var selector in tagSelectors) {
let found = false;