Details
-
Type:
Bug
-
Status: Closed
-
Priority:
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
-
Assignee Priority:P2
-
Support Case References:Support Case #12971 - https://icesoft.my.salesforce.com/5007000000fDO3P
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("\\", "\");
}
return (String)value;
}
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("\\", "\");
}
return (String)value;
}
Activity
- All
- Comments
- History
- Activity
- Remote Attachments
- Subversion
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.