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 2023/01/16 12:27:52 UTC
[myfaces] branch main updated: https://issues.apache.org/jira/browse/MYFACES-4532: Fix for MYFACES-4532
This is an automated email from the ASF dual-hosted git repository.
werpu pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/myfaces.git
The following commit(s) were added to refs/heads/main by this push:
new c073eb0dd https://issues.apache.org/jira/browse/MYFACES-4532: Fix for MYFACES-4532
new 266c6961b Merge pull request #479 from werpu/MYFACES-4532-4.0
c073eb0dd is described below
commit c073eb0dd71cd83485dc624a20f2fd245b15cf3a
Author: Werner Punz <we...@gmail.com>
AuthorDate: Mon Jan 16 13:17:40 2023 +0100
https://issues.apache.org/jira/browse/MYFACES-4532: Fix for MYFACES-4532
---
.../META-INF/resources/myfaces/_impl/_util/_Dom.js | 12 +++++++-----
.../META-INF/resources/myfaces/_impl/_util/_Lang.js | 16 ++++++++++++++++
2 files changed, 23 insertions(+), 5 deletions(-)
diff --git a/api/src/main/javascript/META-INF/resources/myfaces/_impl/_util/_Dom.js b/api/src/main/javascript/META-INF/resources/myfaces/_impl/_util/_Dom.js
index 10ba200db..e28a10da8 100644
--- a/api/src/main/javascript/META-INF/resources/myfaces/_impl/_util/_Dom.js
+++ b/api/src/main/javascript/META-INF/resources/myfaces/_impl/_util/_Dom.js
@@ -1284,7 +1284,9 @@ _MF_SINGLTN(_PFX_UTIL + "_Dom", Object, /** @lends myfaces._impl._util._Dom.prot
//we filter out only those evalNodes which do not match
var _RT = this._RT;
+ var _Lang = this._Lang;
var _T = this;
+
var doubleExistsFilter = function(item) {
switch((item.tagName || "").toLowerCase()) {
case "script":
@@ -1293,9 +1295,9 @@ _MF_SINGLTN(_PFX_UTIL + "_Dom", Object, /** @lends myfaces._impl._util._Dom.prot
var scripts = document.head.getElementsByTagName("script");
for(var cnt = 0; cnt < scripts.length; cnt++) {
- if(src && scripts[cnt].getAttribute("src") == src) {
+ if(src && _Lang.match(scripts[cnt].getAttribute("src"), src)) {
return false;
- } else if(!src && scripts[cnt].innerText == content) {
+ } else if(!src && _Lang.match(scripts[cnt].innerText, content)) {
return false;
}
}
@@ -1304,7 +1306,7 @@ _MF_SINGLTN(_PFX_UTIL + "_Dom", Object, /** @lends myfaces._impl._util._Dom.prot
var content = item.innerText;
var styles = document.head.getElementsByTagName("style");
for(var cnt = 0; cnt < styles.length; cnt++) {
- if(content && styles[cnt].innerText == content) {
+ if(content && _Lang.match(styles[cnt].innerText, content)) {
return false;
}
}
@@ -1314,9 +1316,9 @@ _MF_SINGLTN(_PFX_UTIL + "_Dom", Object, /** @lends myfaces._impl._util._Dom.prot
var content = item.innerText;
var links = document.head.getElementsByTagName("link");
for(var cnt = 0; cnt < links.length; cnt++) {
- if(href && links[cnt].getAttribute("href") == href) {
+ if(href && _Lang.match(links[cnt].getAttribute("href"), href)) {
return false;
- } else if(!href && links[cnt].innerText == content) {
+ } else if(!href && _Lang.match(links[cnt].innerText, content)) {
return false;
}
}
diff --git a/api/src/main/javascript/META-INF/resources/myfaces/_impl/_util/_Lang.js b/api/src/main/javascript/META-INF/resources/myfaces/_impl/_util/_Lang.js
index 9d0e3fe95..c2771158c 100644
--- a/api/src/main/javascript/META-INF/resources/myfaces/_impl/_util/_Lang.js
+++ b/api/src/main/javascript/META-INF/resources/myfaces/_impl/_util/_Lang.js
@@ -214,6 +214,22 @@ _MF_SINGLTN(_PFX_UTIL + "_Lang", Object, /** @lends myfaces._impl._util._Lang.pr
}
return str.slice(0, i + 1);
},
+
+ /**
+ * a fuzzy match where one item is subset of the other or vice versa
+ * @param str1
+ * @param str2
+ * @returns {boolean}
+ */
+ match: function(str1, str2) {
+ //Sometimes we have to deal with paths in hrefs so
+ //one of the itmes either is an exact match or a substring
+ str1 = this.trim(str1 || "");
+ str2 = this.trim(str2 || "");
+
+ return str1.indexOf(str2) != -1 || str2.indexOf(str1) != -1;
+ },
+
/**
* Backported from dojo
* a failsafe string determination method