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 13:58:52 UTC
svn commit: r959627 - in
/myfaces/core/trunk/api/src/main/javascript/META-INF/resources/myfaces/_impl:
_util/_Dom.js _util/_Lang.js core/_Runtime.js xhrCore/_AjaxResponse.js
Author: werpu
Date: Thu Jul 1 11:58:51 2010
New Revision: 959627
URL: http://svn.apache.org/viewvc?rev=959627&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
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/_util/_Lang.js
myfaces/core/trunk/api/src/main/javascript/META-INF/resources/myfaces/_impl/core/_Runtime.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=959627&r1=959626&r2=959627&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 11:58:51 2010
@@ -79,7 +79,7 @@ myfaces._impl.core._Runtime.singletonExt
myfaces._impl.core._Runtime.loadScriptEval(src, item.getAttribute('type'), false, "UTF-8");
} else {
// embedded script auto eval
- var test = (!xmlData) ? item.text :myfaces._impl._util._Lang.serializeChilds(item);
+ var test = (!xmlData) ? item.text : myfaces._impl._util._Lang.serializeChilds(item);
var go = true;
while (go) {
go = false;
@@ -290,8 +290,8 @@ myfaces._impl.core._Runtime.singletonExt
findById : function(fragment, itemId) {
//we have to escape here
- if (fragment === document) {
- return this.byId(itemId);
+ if (fragment.getElementById) {
+ return fragment.getElementById(itemId);
}
if (fragment.nodeType == 1 && fragment.querySelector) {
@@ -410,33 +410,22 @@ myfaces._impl.core._Runtime.singletonExt
deepScan = !!deepScan;
+ //elements by tagname is the fastest
+ if (deepScan && fragment.getElementsByTagName) {
+ var ret = _Lang.objToArray(fragment.getElementsByTagName(tagName));
+ if(fragment.tagName && fragment.tagName.toLowerCase() == tagName.toLocaleLowerCase()) ret.unshift(fragment);
+ return ret;
+ }
+ //since getElementsByTagName is a standardized dom node function and ie also supports
+ //it since 5.5
+ //we need no fallback to the query api and the recursive filter
+ //also is only needed in case of no deep scan or non dom elements
+
var filter = function(node) {
return node.tagName && _Lang.equalsIgnoreCase(node.tagName, tagName);
};
try {
-
- try {
- //html 5 selector
- if (deepScan && fragment.querySelectorAll) {
- var newTagName = tagName;
- if (_Lang.isString(newTagName)) {
- var newTagName = newTagName.replace(/\./g, "\\.");
- }
- var result = fragment.querySelectorAll(newTagName);
- if (fragment.nodeType == 1 && filter(fragment)) {
- result = (result == null) ? [] : _Lang.objToArray(result);
- result.push(fragment);
- }
- return result;
- }
- } catch (e) {
- //in case the selector fails we have to do another fallback instead
- //of throwing an error
- }
- //if we are not in a html 5 environment which supports node selectors
- //we use the usual recursive fallback.
return this.findAll(fragment, filter, deepScan);
-
} finally {
//the usual IE6 is broken, fix code
filter = null;
@@ -453,6 +442,15 @@ myfaces._impl.core._Runtime.singletonExt
try {
deepScan = !!deepScan;
+ //elements byName is the fastest
+ if (deepScan && fragment.getElementsByName) {
+ var ret = _Lang.objToArray(fragment.getElementsByName(name));
+ if(fragment.name == name) ret.unshift(fragment);
+ return ret;
+
+ }
+
+
if (deepScan && fragment.querySelectorAll) {
try {
var newName = name;
@@ -504,13 +502,16 @@ myfaces._impl.core._Runtime.singletonExt
deepScan = !!deepScan;
//html5 getElementsByClassname
- if (fragment.getElementsByClassName && deepScan) {
+
+ //TODO implement this
+ /*if (fragment.getElementsByClassName && deepScan) {
return fragment.getElementsByClassName(styleClass);
}
+
//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 (fragment.querySelectorAll && deepScan) {
try {
var result = fragment.querySelectorAll("." + styleClass.replace(/\./g, "\\."));
Modified: myfaces/core/trunk/api/src/main/javascript/META-INF/resources/myfaces/_impl/_util/_Lang.js
URL: http://svn.apache.org/viewvc/myfaces/core/trunk/api/src/main/javascript/META-INF/resources/myfaces/_impl/_util/_Lang.js?rev=959627&r1=959626&r2=959627&view=diff
==============================================================================
--- myfaces/core/trunk/api/src/main/javascript/META-INF/resources/myfaces/_impl/_util/_Lang.js (original)
+++ myfaces/core/trunk/api/src/main/javascript/META-INF/resources/myfaces/_impl/_util/_Lang.js Thu Jul 1 11:58:51 2010
@@ -371,19 +371,14 @@ myfaces._impl.core._Runtime.singletonDel
return arr.join(delimiter);
},
- /**
- * general type assertion routine
- *
- * @param probe the probe to be checked for the correct type
- * @param theType the type to be checked for
- */
- assertType : function(probe, theType) {
- return this.isString(theType) ? probe == typeof theType : probe instanceof theType;
- },
+
objToArray: function(obj, offset, pack) {
+ if(!obj) {
+ return null;
+ }
//since offset is numeric we cannot use the shortcut due to 0 being false
var finalOffset = ('undefined' != typeof offset || null != offset) ? offset : 0;
var finalPack = pack || [];
Modified: myfaces/core/trunk/api/src/main/javascript/META-INF/resources/myfaces/_impl/core/_Runtime.js
URL: http://svn.apache.org/viewvc/myfaces/core/trunk/api/src/main/javascript/META-INF/resources/myfaces/_impl/core/_Runtime.js?rev=959627&r1=959626&r2=959627&view=diff
==============================================================================
--- myfaces/core/trunk/api/src/main/javascript/META-INF/resources/myfaces/_impl/core/_Runtime.js (original)
+++ myfaces/core/trunk/api/src/main/javascript/META-INF/resources/myfaces/_impl/core/_Runtime.js Thu Jul 1 11:58:51 2010
@@ -277,7 +277,6 @@ if (!myfaces._impl.core._Runtime) {
return (!_this.exists(localOptions, "myfaces." + configName)) ? _this.getGlobalConfig(configName, defaultValue) : localOptions.myfaces[configName];
};
-
/**
* encapsulated xhr object which tracks down various implementations
@@ -382,12 +381,12 @@ if (!myfaces._impl.core._Runtime) {
}
//fix for the white page issue
- // if(this.browser.isIE && this.browser.isIE < 7) {
+ // if(this.browser.isIE && this.browser.isIE < 7) {
// holder.insertBefore( script, holder.firstChild );
// holder.removeChild( script );
- // } else {
- holder.appendChild(script);
- // }
+ // } else {
+ holder.appendChild(script);
+ // }
} catch (e) {
//in case of a loading error we retry via eval
@@ -402,7 +401,7 @@ if (!myfaces._impl.core._Runtime) {
//a correct order of scripts being loaded
//if you use script source on the head, we have to revert
//to xhr+ globalEval for those
- if(!_this.browser.isFF) {
+ if (!_this.browser.isFF) {
_this.loadScriptEval(src, type, defer, charSet);
} else {
//only firefox keeps the order, sorry ie...
@@ -626,6 +625,16 @@ if (!myfaces._impl.core._Runtime) {
};
/**
+ * general type assertion routine
+ *
+ * @param probe the probe to be checked for the correct type
+ * @param theType the type to be checked for
+ */
+ this.assertType = function(probe, theType) {
+ return this.isString(theType) ? probe == typeof theType : probe instanceof theType;
+ };
+
+ /**
* onload wrapper for chaining the onload cleanly
* @param func the function which should be added to the load
* chain (note we cannot rely on return values here, hence jsf.util.chain will fail)
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=959627&r1=959626&r2=959627&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 11:58:51 2010
@@ -410,16 +410,21 @@ myfaces._impl.core._Runtime.extendClass(
},
_replaceHead: function(request, context, newData) {
+ var _Impl = myfaces._impl.core._Runtime.getGlobalConfig("jsfAjaxImpl", myfaces._impl.core.Impl);
var doc = this._Lang.parseXML(newData);
var newHead = null;
if(this._Lang.isXMLParseError(doc)) {
+ doc = this._Lang.parseXML(newData.replace(/<!\-\-[\s\n]*<!\-\-/g,"<!--").replace(/\/\/-->[\s\n]\/\/-->/g,"//-->"));
+ }
+
+ if(this._Lang.isXMLParseError(doc)) {
//the standard xml parser failed we retry with the stripper
var parser = new (myfaces._impl.core._Runtime.getGlobalConfig("updateParser", myfaces._impl._util._HtmlStripper))();
var headData = parser.parse(newData, "head");
newHead = this._Lang.parseXML("<root>"+headData+"</root>");
if(this._Lang.isXMLParseError(newHead)) {
//we give up no further fallbacks
- this._Impl.sendError(request, context, _Impl.MALFORMEDXML, _Impl.MALFORMEDXML, "Error in PPR Insert, before id or after id must be present");
+ _Impl.sendError(request, context, _Impl.MALFORMEDXML, _Impl.MALFORMEDXML, "Error in PPR Insert, before id or after id must be present");
return;
}
} else {
@@ -468,6 +473,10 @@ myfaces._impl.core._Runtime.extendClass(
var bodyData = null;
var doc = this._Lang.parseXML(newData);
if(this._Lang.isXMLParseError(doc)) {
+ doc = this._Lang.parseXML(newData.replace(/<!\-\-[\s\n]*<!\-\-/g,"<!--").replace(/\/\/-->[\s\n]\/\/-->/g,"//-->"));
+ }
+
+ if(this._Lang.isXMLParseError(doc)) {
//the standard xml parser failed we retry with the stripper
var parser = new (myfaces._impl.core._Runtime.getGlobalConfig("updateParser", myfaces._impl._util._HtmlStripper))();
bodyData = parser.parse(newData, "body");