Index: jsf-api/resources/jsf.js
===================================================================
--- jsf-api/resources/jsf.js (revision 7523)
+++ jsf-api/resources/jsf.js Thu Jul 23 17:55:35 EEST 2009
@@ -331,21 +331,85 @@
var parent = d.parentNode;
// Trim space padding before assigning to innerHTML
var html = str.replace(/^\s+/g,'').replace(/\s+$/g,'');
+ var parserElement = document.createElement('div');
var tableElements = ['td', 'th', 'tr', 'tbody', 'thead', 'tfoot'];
- var isInTable = tableElements[d.tagName.toLocaleLowerCase()];
+ var tag = d.tagName.toLocaleLowerCase();
+ var isInTable = tableElements.indexOf(tag) >= 0;
if (isInTable) {
- temp = document.createElement('table');
- temp.innerHTML = html;
- var newElement = temp.firstChild;
+ parserElement.innerHTML = '
';
+ var newElement = parserElement.firstChild;
//some browsers will also create intermediary elements such as table>tbody>tr>td
while ((null != newElement) && (id != newElement.id)) {
newElement = newElement.firstChild;
}
parent.replaceChild(newElement, d);
+ } else if (tag == 'input') { //special case handling for 'input' elements
+ parserElement.innerHTML = html;
+ var newElement = parserElement.firstChild;
+
+ var InputElementAttributes =
+ //core and i18n attributes (except 'id' and 'style' attributes)
+ ['className', 'title', 'lang',
+ //input element attributes
+ 'name', 'value', 'checked', 'disabled', 'readOnly',
+ 'size', 'maxLength', 'src', 'alt', 'useMap', 'isMap',
+ 'tabIndex', 'accessKey', 'accept'];
+ //'dir' attribute cannot be updated dynamically in IE 7
+ //'type' attribute cannot be updated dynamically in Firefox 2.0
+ for (var iIndex = 0, iLength = InputElementAttributes.length; iIndex < iLength; iIndex++) {
+ var attributeName = InputElementAttributes[iIndex];
+ var newValue = newElement[attributeName];
+ var oldValue = d[attributeName];
+ if (oldValue != newValue) {
+ d[attributeName] = newValue;
+ }
+ }
+
+ var ElementStyleProperties = [
+ 'backgroundAttachment', 'backgroundColor', 'backgroundImage', 'backgroundPosition', 'backgroundRepeat',
+ 'borderBottom', 'borderBottomColor', 'borderBottomStyle', 'borderBottomWidth', 'borderColor', 'borderLeft',
+ 'borderLeftColor', 'borderLeftStyle', 'borderLeftWidth', 'borderRight', 'borderRightColor', 'borderRightStyle',
+ 'borderRightWidth', 'borderStyle', 'borderTop', 'borderTopColor', 'borderTopStyle', 'borderTopWidth', 'borderWidth',
+ 'fontFamily', 'fontSize', 'fontVariant', 'fontWeight',
+ 'letterSpacing', 'lineHeight',
+ 'listStyle', 'listStyleImage', 'listStylePosition', 'listStyleType',
+ 'marginBottom', 'marginLeft', 'marginRight', 'marginTop',
+ 'paddingBottom', 'paddingLeft', 'paddingRight', 'paddingTop',
+ 'pageBreakAfter', 'pageBreakBefore',
+ 'textAlign', 'textDecorationBlink', 'textDecorationLineThrough', 'textDecorationNone', 'textDecorationOverline',
+ 'textDecorationUnderline', 'textIndent', 'textTransform',
+ 'clear', 'filter', 'clip', 'color', 'cursor', 'display', 'visibility',
+ 'top', 'left', 'width', 'height',
+ 'verticalAlign', 'position' , 'zIndex', 'overflow', 'styleFloat'
+ ];
+ //'style' attribute special case
+ var newStyle = newElement.getAttribute('style');
+ var oldStyle = d.getAttribute('style');
+ if (newStyle != oldStyle) {
+ d.setAttribute('style', newStyle);
+
+ var elementStyle = d.style;
+ var newElementStyle = newElement.style;
+ for (var sIndex = 0, sLength = ElementStyleProperties.length; sIndex < sLength; sIndex++) {
+ var p = ElementStyleProperties[sIndex];
+ if (!(p != "font" && newElementStyle[p])) {
+ elementStyle[p] = newElementStyle[p];
+ }
+ };
+ }
+
+ var listenerNames = [
+ 'onclick', 'ondblclick', 'onmousedown', 'onmousemove', 'onmouseout', 'onmouseover', 'onmouseup',
+ 'onkeydown', 'onkeypress', 'onkeyup', 'onhelp', 'onblur', 'onfocus', 'onchange'
+ ];
+ for (var lIndex = 0, lLength = listenerNames.length; lIndex < lLength; lIndex++) {
+ var name = listenerNames[lIndex];
+ d[name] = newElement[name] ? newElement[name] : null;
+ newElement[name] = null;
+ }
} else {
- temp = document.createElement('div');
- temp.innerHTML = html;
- parent.replaceChild(temp.firstChild, d);
+ parserElement.innerHTML = html;
+ parent.replaceChild(parserElement.firstChild, d);
}
}
};