ICEfaces
  1. ICEfaces
  2. ICE-10155

Backslashes not being converted properly in DOM diffs

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: EE-3.3.0.GA_P02
    • Fix Version/s: 4.0, EE-3.3.0.GA_P03
    • Component/s: Framework
    • Labels:
      None
    • Environment:
      n/a

      Description

      Backslashes in select option values are causing unnecessary DOM diffs. The DOM diff is always showing properly escaped backslashes (\\) in the previous DOM, but not in the new DOM. The difference between '\\' and '\' is then detected during the diff and the select element options will always be included in the diff, even if nothing has changed in the rendering.

      debug A:
       element[tag: select; attributes: id=j_idt4:_t5 name=j_idt4:_t5 onchange=mojarra.ab(this,event,'change','@this','@all') size=1 ]
              text[ <option value="" selected="true">Please select one..</option>
        <option value="A">A</option>
        <option value="B">B</option>
        <option value="This is a backslash: \">This is a backslash: \\</option>

      debug B:
      element[tag: select; attributes: id=j_idt4:_t5 name=j_idt4:_t5 onchange=mojarra.ab(this,event,'change','@this','@all') size=1 ]
              text[ <option value="" selected="true">Please select one..</option>
        <option value="A">A</option>
        <option value="B">B</option>
        <option value="This is a backslash: \">This is a backslash: \</option>

      This issue with backslashes seems to only occur with select elements, and not in other text nodes or element attributes. InputText components and free-standing text with backslashes appears unaffected.

      A simple workaround is to include a String converter in the select component that will replace the backslash with a unicode character:

      public String getAsString(FacesContext context, UIComponent component,
      Object value) throws ConverterException {
      if( value != null && value instanceof String){
      value = ((String)value).replace("\\", "&#x5C;");
      }

      return (String)value;
      }

        Activity

        Hide
        Mircea Toma added a comment -

        Modified DOMPartialViewContext.applyBrowserChanges method to replace quote (") characters with their Regex equivalent (\") when calling Matcher.appendReplacement to avoid having the backslashes found in the DOM attributes interpreted as an escape characters for the quotes.

        Show
        Mircea Toma added a comment - Modified DOMPartialViewContext.applyBrowserChanges method to replace quote (") characters with their Regex equivalent (\") when calling Matcher.appendReplacement to avoid having the backslashes found in the DOM attributes interpreted as an escape characters for the quotes.

          People

          • Assignee:
            Mircea Toma
            Reporter:
            Philip Breau
          • Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: