You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by we...@apache.org on 2010/07/01 16:34:22 UTC
svn commit: r959680 - in
/myfaces/core/trunk/api/src/main/javascript/META-INF/resources/myfaces/_impl:
_util/_Dom.js xhrCore/_AjaxResponse.js
Author: werpu
Date: Thu Jul 1 14:34:22 2010
New Revision: 959680
URL: http://svn.apache.org/viewvc?rev=959680&view=rev
Log:
https://issues.apache.org/jira/browse/MYFACES-2761
fixed a minor issue with a wrong _Lang reference caused by the new head code
workaround for:
https://issues.apache.org/jira/browse/MYFACES-2781
so that the code can be tested, will be removed as soon as it is fixed on the server side
added ie fixes
Modified:
myfaces/core/trunk/api/src/main/javascript/META-INF/resources/myfaces/_impl/_util/_Dom.js
myfaces/core/trunk/api/src/main/javascript/META-INF/resources/myfaces/_impl/xhrCore/_AjaxResponse.js
Modified: myfaces/core/trunk/api/src/main/javascript/META-INF/resources/myfaces/_impl/_util/_Dom.js
URL: http://svn.apache.org/viewvc/myfaces/core/trunk/api/src/main/javascript/META-INF/resources/myfaces/_impl/_util/_Dom.js?rev=959680&r1=959679&r2=959680&view=diff
==============================================================================
--- myfaces/core/trunk/api/src/main/javascript/META-INF/resources/myfaces/_impl/_util/_Dom.js (original)
+++ myfaces/core/trunk/api/src/main/javascript/META-INF/resources/myfaces/_impl/_util/_Dom.js Thu Jul 1 14:34:22 2010
@@ -411,7 +411,7 @@ myfaces._impl.core._Runtime.singletonExt
deepScan = !!deepScan;
//elements by tagname is the fastest
- if (deepScan && fragment.getElementsByTagName) {
+ if (deepScan && _Lang.exists(fragment, "getElementsByTagName")) {
var ret = _Lang.objToArray(fragment.getElementsByTagName(tagName));
if(fragment.tagName && fragment.tagName.toLowerCase() == tagName.toLocaleLowerCase()) ret.unshift(fragment);
return ret;
@@ -443,7 +443,7 @@ myfaces._impl.core._Runtime.singletonExt
deepScan = !!deepScan;
//elements byName is the fastest
- if (deepScan && fragment.getElementsByName) {
+ if (deepScan && _Lang.exists(fragment, "getElementsByName")) {
var ret = _Lang.objToArray(fragment.getElementsByName(name));
if(fragment.name == name) ret.unshift(fragment);
return ret;
@@ -451,12 +451,11 @@ myfaces._impl.core._Runtime.singletonExt
}
- if (deepScan && fragment.querySelectorAll) {
+ if (deepScan && _Lang.exists(fragment, "querySelectorAll")) {
try {
var newName = name;
if (_Lang.isString(newName)) {
newName = newName.replace(/\./g, "\\.").replace(/:/g, "\\:");
- ;
}
var result = fragment.querySelectorAll("[name=" + newName + "]");
if (fragment.nodeType == 1 && filter(fragment)) {
@@ -511,7 +510,8 @@ myfaces._impl.core._Runtime.singletonExt
//html5 speed optimization for browsers which do not ,
//have the getElementsByClassName implemented
//but only for deep scan and normal parent nodes
- else */if (fragment.querySelectorAll && deepScan) {
+ else */
+ if (_Lang.exists(fragment, "querySelectorAll") && deepScan) {
try {
var result = fragment.querySelectorAll("." + styleClass.replace(/\./g, "\\."));
Modified: myfaces/core/trunk/api/src/main/javascript/META-INF/resources/myfaces/_impl/xhrCore/_AjaxResponse.js
URL: http://svn.apache.org/viewvc/myfaces/core/trunk/api/src/main/javascript/META-INF/resources/myfaces/_impl/xhrCore/_AjaxResponse.js?rev=959680&r1=959679&r2=959680&view=diff
==============================================================================
--- myfaces/core/trunk/api/src/main/javascript/META-INF/resources/myfaces/_impl/xhrCore/_AjaxResponse.js (original)
+++ myfaces/core/trunk/api/src/main/javascript/META-INF/resources/myfaces/_impl/xhrCore/_AjaxResponse.js Thu Jul 1 14:34:22 2010
@@ -356,8 +356,8 @@ myfaces._impl.core._Runtime.extendClass(
switch (node.getAttribute('id')) {
case this.P_VIEWROOT:
cDataBlock = cDataBlock.substring(cDataBlock.indexOf("<html"));
- this._replaceHead(request, context, cDataBlock);
- var resultNode = this._replaceBody(request, context, cDataBlock);
+ var parsedData = this._replaceHead(request, context, cDataBlock);
+ var resultNode = (parsedData)? this._replaceBody(request, context, cDataBlock, parsedData): this._replaceBody(request, context, cDataBlock);
if (resultNode) {
this._pushOperationResult(resultNode);
}
@@ -409,6 +409,17 @@ myfaces._impl.core._Runtime.extendClass(
},
+ /**
+ * replaces a current head theoretically,
+ * pratically only the scripts are evaled anew since nothing else
+ * can be changed.
+ *
+ * @param request the current request
+ * @param context the ajax context
+ * @param newData the data to be processed
+ *
+ * @return an xml representation of the page for further processing if possible
+ */
_replaceHead: function(request, context, newData) {
var _Impl = myfaces._impl.core._Runtime.getGlobalConfig("jsfAjaxImpl", myfaces._impl.core.Impl);
var doc = this._Lang.parseXML(newData);
@@ -425,7 +436,7 @@ myfaces._impl.core._Runtime.extendClass(
if(this._Lang.isXMLParseError(newHead)) {
//we give up no further fallbacks
_Impl.sendError(request, context, _Impl.MALFORMEDXML, _Impl.MALFORMEDXML, "Error in PPR Insert, before id or after id must be present");
- return;
+ return null;
}
} else {
//parser worked we go on
@@ -437,6 +448,8 @@ myfaces._impl.core._Runtime.extendClass(
//prestripping the body should reduce the failure rate of this method
///var xmlData = this._Lang.parseXML("<root>"+headData+"</root>");
this._Dom.runScripts(newHead, true);
+
+ return doc;
},
@@ -449,8 +462,9 @@ myfaces._impl.core._Runtime.extendClass(
* @param {Object} request our request object
* @param {Object} context (Map) the response context
* @param {String} newData the markup which replaces the old dom node!
+ * @param {Node} parsedData (optional) preparsed XML representation data of the current document
*/
- _replaceBody : function(request, context, newData) {
+ _replaceBody : function(request, context, newData /*varargs*/) {
var parser = new (myfaces._impl.core._Runtime.getGlobalConfig("updateParser", myfaces._impl._util._HtmlStripper))();
var oldBody = document.getElementsByTagName("body")[0];
@@ -471,7 +485,7 @@ myfaces._impl.core._Runtime.extendClass(
//and if that fails revert to a hidden iframe
//var bodyData = parser.parse(newData, "body");
var bodyData = null;
- var doc = this._Lang.parseXML(newData);
+ var doc = (arguments.length > 3)? arguments[4]: this._Lang.parseXML(newData);
if(this._Lang.isXMLParseError(doc)) {
doc = this._Lang.parseXML(newData.replace(/<!\-\-[\s\n]*<!\-\-/g,"<!--").replace(/\/\/-->[\s\n]\/\/-->/g,"//-->"));
}