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

        Arran Mccullough created issue -
        Arran Mccullough made changes -
        Field Original Value New Value
        Attachment Chrome_js_error.jpg [ 13399 ]
        Arran Mccullough made changes -
        Attachment Case10339Example.war [ 13400 ]
        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()) ...
        Ken Fyten made changes -
        Salesforce Case []
        Component/s Bridge [ 10011 ]
        Component/s Components [ 10012 ]
        Fix Version/s EE-2.0.0.GA_P01 [ 10271 ]
        Fix Version/s 2.1 [ 10241 ]
        Assignee Priority P2
        Assignee Mircea Toma [ mircea.toma ]
        Arran Mccullough made changes -
        Salesforce Case [5007000000HzdP2]
        Repository Revision Date User Message
        ICEsoft Public SVN Repository #25166 Wed Aug 03 14:30:01 MDT 2011 mircea.toma ICE-7096 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.
        Files Changed
        Commit graph MODIFY /icefaces/trunk/icefaces/bridge/lib/element.js
        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.
        Mircea Toma made changes -
        Status Open [ 1 ] Resolved [ 5 ]
        Fix Version/s EE-1.8.2.GA_P04 [ 10280 ]
        Fix Version/s 1.8.3 [ 10211 ]
        Fix Version/s EE-2.0.0.GA_P01 [ 10271 ]
        Fix Version/s 2.1 [ 10241 ]
        Resolution Fixed [ 1 ]
        Ken Fyten made changes -
        Status Resolved [ 5 ] Closed [ 6 ]
        Assignee Priority P2

          People

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

            Dates

            • Created:
              Updated:
              Resolved: