ICEfaces
  1. ICEfaces
  2. ICE-7096

JavaScript error when calling iceSubmitPartial in Chrome

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: EE-1.8.2.GA_P03
    • Fix Version/s: 1.8.3, EE-1.8.2.GA_P04
    • Component/s: Bridge
    • Labels:
      None
    • Environment:
      Chrome

      Description

      A JavaScript error is thrown when calling the iceSubmitPartial JavaScript code in a function that is called on the body tags onload method.

        Activity

        Hide
        Arran Mccullough added a comment -

        Dev comments on cause of issue:

        The error occurs here where it tries to get the tagName of the passed in element:

        This.Element.adaptToElement = function(e) {
        //no polymophism here...'switch' is the way then.
        if (!e)
        return new This.Element(e);
        switch (e.tagName.toLowerCase())

        { case 'textarea': case 'input': return new This.InputElement(e); case 'thead': case 'tfoot': case 'tbody': case 'th': case 'td': case 'tr': return new This.TableCellElement(e); case 'button': return new This.ButtonElement(e); case 'select': return new This.SelectElement(e); case 'form': return new This.FormElement(e); case 'body': return new This.BodyElement(e); case 'script': return new This.ScriptElement(e); case 'title': return new This.TitleElement(e); case 'a': return new This.AnchorElement(e); case 'iframe': return new This.IFrameElement(e); default : return new This.Element(e); }

        };

        Not sure why Chrome would have an issue with this compared to the other browsers. If I debug it a bit, it seems that during processing, the event.source is determined to be an HTMLDocument (which I guess makes a certain sense for the onload) but in Chrome, the HTMLDocument does not have a tagName attribute and this is what causes the exception to be thrown. I guess a fix would be to check for e.tagName and just return This.Element(e) for that as well:

        This.Element.adaptToElement = function(e) {
        //no polymophism here...'switch' is the way then.
        if (!e)
        return new This.Element(e);

        if (!e.tagName)
        return new This.Element(e);

        switch (e.tagName.toLowerCase()) {
        case 'textarea':

        Show
        Arran Mccullough added a comment - Dev comments on cause of issue: The error occurs here where it tries to get the tagName of the passed in element: This.Element.adaptToElement = function(e) { //no polymophism here...'switch' is the way then. if (!e) return new This.Element(e); switch (e.tagName.toLowerCase()) { case 'textarea': case 'input': return new This.InputElement(e); case 'thead': case 'tfoot': case 'tbody': case 'th': case 'td': case 'tr': return new This.TableCellElement(e); case 'button': return new This.ButtonElement(e); case 'select': return new This.SelectElement(e); case 'form': return new This.FormElement(e); case 'body': return new This.BodyElement(e); case 'script': return new This.ScriptElement(e); case 'title': return new This.TitleElement(e); case 'a': return new This.AnchorElement(e); case 'iframe': return new This.IFrameElement(e); default : return new This.Element(e); } }; Not sure why Chrome would have an issue with this compared to the other browsers. If I debug it a bit, it seems that during processing, the event.source is determined to be an HTMLDocument (which I guess makes a certain sense for the onload) but in Chrome, the HTMLDocument does not have a tagName attribute and this is what causes the exception to be thrown. I guess a fix would be to check for e.tagName and just return This.Element(e) for that as well: This.Element.adaptToElement = function(e) { //no polymophism here...'switch' is the way then. if (!e) return new This.Element(e); if (!e.tagName) return new This.Element(e); switch (e.tagName.toLowerCase()) { case 'textarea':
        Hide
        Arran Mccullough added a comment -

        Deryk's correct, the event's 'srcElement' property is the HTMLDocument which does not have a 'tagName' property. A simpler solution that has been adopted lately is to use the 'nodeName' property instead because it always returns a string for any type of DOM node:

        ...
        switch (e.nodeName.toLowerCase())
        ...

        Show
        Arran Mccullough added a comment - Deryk's correct, the event's 'srcElement' property is the HTMLDocument which does not have a 'tagName' property. A simpler solution that has been adopted lately is to use the 'nodeName' property instead because it always returns a string for any type of DOM node: ... switch (e.nodeName.toLowerCase()) ...
        Hide
        Mircea Toma added a comment -

        Use Node.nodeName property to acquire the element's tag name, in case the passed in node does not have a tag name the 'nodeName' will still return a non-null name.

        Show
        Mircea Toma added a comment - Use Node.nodeName property to acquire the element's tag name, in case the passed in node does not have a tag name the 'nodeName' will still return a non-null name.

          People

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

            Dates

            • Created:
              Updated:
              Resolved: