MyFaces Core
  1. MyFaces Core
  2. MYFACES-3509

Array.prototype.forEach used in browsers that do not natively support this function

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 2.0.14, 2.1.8
    • Component/s: General
    • Labels:
      None
    • Environment:
      IE8

      Description

      While running one of our test applications in IE8 we got this "Object doesn't support this property or method" error occurring.
      After debugging the code the problem was located in api/src/main/javascript/META-INF/resources/myfaces/_impl/_util/_Lang.js code. It seems that 'arrForEach' is trying to use the browser native 'forEach' function but it fails since IE8 (or IE7) does not implement it.

      Here is a constructed call stack that shows when and where the error occurs:

      (startPos) ? arr.slice(startPos).forEach(func, thisObj) : arr.forEach(func, thisObj); – file: api/src/main/javascript/META-INF/resources/myfaces/_impl/_util/_Lang.js, line: 346
      this._Lang.arrForEach(this._q, closure, this._space); – file: api/src/main/javascript/META-INF/resources/myfaces/_impl/_util/_Queue.js, line: 155
      this.each(broadCastFunc); – file: api/src/main/javascript/META-INF/resources/myfaces/_impl/_util/_ListenerQueue.js, line: 80
      this._evtListeners.broadcastEvent(eventData); – file: api/src/main/javascript/META-INF/resources/myfaces/_impl/core/Impl.js, line: 564
      ....

      I noticed that in api/src/main/javascript/META-INF/resources/myfaces/_impl/_util/_LangQuirks.js there's a version of 'arrForEach' function that iterates over elements using a plain 'for' loop. Unfortunately this version of the method is not loaded because of the condition at the top of the file is not fulfilled. I attached a patch that we used to get things going. Of course you might have a better solution to this issue.

      Here's also the original JIRA case: http://jira.icesoft.org/browse/ICE-7899

      1. MYFACES-3509-1.patch
        0.6 kB
        Leonardo Uribe

        Activity

          People

          • Assignee:
            Unassigned
            Reporter:
            Mircea Toma
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development