You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by lo...@apache.org on 2019/06/13 12:37:56 UTC

[myfaces-tobago] 02/02: TOBAGO-1633: TS refactoring: MS edge compatibility

This is an automated email from the ASF dual-hosted git repository.

lofwyr pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/myfaces-tobago.git

commit bf949f881515436d54b8c86a912d2621c7bfe0de
Author: Udo Schnurpfeil <lo...@apache.org>
AuthorDate: Thu Jun 13 14:37:45 2019 +0200

    TOBAGO-1633: TS refactoring: MS edge compatibility
    
    edge doen't support [Symbol.iterator] on the result
    of getElementsByClassName, so "for of" is not possible.
---
 .../src/main/npm/ts/tobago-split-layout.ts           | 20 +++++++++++---------
 .../src/main/npm/ts/tobago-utils.ts                  |  5 +++--
 2 files changed, 14 insertions(+), 11 deletions(-)

diff --git a/tobago-theme/tobago-theme-standard/src/main/npm/ts/tobago-split-layout.ts b/tobago-theme/tobago-theme-standard/src/main/npm/ts/tobago-split-layout.ts
index 8d00105..5124a61 100644
--- a/tobago-theme/tobago-theme-standard/src/main/npm/ts/tobago-split-layout.ts
+++ b/tobago-theme/tobago-theme-standard/src/main/npm/ts/tobago-split-layout.ts
@@ -33,13 +33,15 @@ class SplitLayout {
   constructor(element: HTMLDivElement) {
     this.element = element;
 
-    for (const splitter of this.element.getElementsByClassName("tobago-splitLayout-horizontal")) {
-      splitter.addEventListener("mousedown", this.start.bind(this));
+    let splitters = this.element.getElementsByClassName("tobago-splitLayout-horizontal");
+    for (let i = 0; i < splitters.length; i++) {
+      splitters.item(i).addEventListener("mousedown", this.start.bind(this));
       this.horizontal = true;
     }
 
-    for (const splitter of this.element.getElementsByClassName("tobago-splitLayout-vertical")) {
-      splitter.addEventListener("mousedown", this.start.bind(this));
+    splitters = this.element.getElementsByClassName("tobago-splitLayout-vertical");
+    for (let i = 0; i < splitters.length; i++) {
+      splitters.item(i).addEventListener("mousedown", this.start.bind(this));
       this.horizontal = false;
     }
   }
@@ -75,8 +77,8 @@ class SplitLayout {
   };
 
   stop(event: MouseEvent): void {
-    document.removeEventListener("mousemove", this.move.bind(this));
-    document.removeEventListener("mouseup", this.stop.bind(this));
+    document.removeEventListener("mousemove", this.move.bind(this)); // fixme remove the real added
+    document.removeEventListener("mouseup", this.stop.bind(this)); // fixme remove the real added
     SplitLayoutMousedown.remove();
   };
 }
@@ -131,9 +133,9 @@ class SplitLayoutMousedown {
   private static indexOfSplitter(splitter: HTMLElement, horizontal: boolean): number {
     const list = splitter.parentElement.getElementsByClassName(
         horizontal ? "tobago-splitLayout-horizontal" : "tobago-splitLayout-vertical");
-    for (let k = 0; k < list.length; k++) {
-      if (list.item(k) === splitter) {
-        return k;
+    for (let i = 0; i < list.length; i++) {
+      if (list.item(i) === splitter) {
+        return i;
       }
     }
     return -1;
diff --git a/tobago-theme/tobago-theme-standard/src/main/npm/ts/tobago-utils.ts b/tobago-theme/tobago-theme-standard/src/main/npm/ts/tobago-utils.ts
index cfd5d26..7b6d2bb 100644
--- a/tobago-theme/tobago-theme-standard/src/main/npm/ts/tobago-utils.ts
+++ b/tobago-theme/tobago-theme-standard/src/main/npm/ts/tobago-utils.ts
@@ -39,8 +39,9 @@ export class DomUtils {
     if (element.classList.contains(className)) {
       result.push(element);
     }
-    for (const found of element.getElementsByClassName(className)) {
-      result.push(<HTMLElement>found);
+    const list = element.getElementsByClassName(className);
+    for (let i = 0; i < list.length; i++) {
+      result.push(<HTMLElement>list.item(i));
     }
     return result;
   };