[ 
https://issues.apache.org/jira/browse/MYFACES-4532?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17677314#comment-17677314
 ] 

Werner Punz edited comment on MYFACES-4532 at 1/16/23 10:44 AM:
----------------------------------------------------------------

Found the issue the doubleInclude filter is failing because it searchs for an 
exact match:

 
{code:javascript}
var doubleExistsFilter = function(item)  {

...

 var links = document.head.getElementsByTagName("link");
                    for(var cnt = 0; cnt < links.length; cnt++) {
                        if(href && links[cnt].getAttribute("href") == href)

{                             return false;                         }

else if(!href && links[cnt].innerText == content) \{                            
 return false;                         }

                    }

}

 

links[cnt].getAttribute("href")
'http://localhost:8080/d1674ff9-e45d-46c3-9c33-f093c2e486c5/jakarta.faces.resource/addedViaInclude.css.xhtml?ln=spec1423'
href
'/d1674ff9-e45d-46c3-9c33-f093c2e486c5/jakarta.faces.resource/addedViaInclude.css.xhtml?ln=spec1423'

 

{code}
The filter always indicates the element does not exist because the match always 
will return false, due to having the url prefixed and in the second case only 
the path without url.

The reason why this works in the new code is, because we use a pattern query 
(which I cannot use in the old one, due to legacy browser support:

 
{code:javascript}
function resourceIsNew(element: DomQuery) {

...

return !head.querySelectorAll(`${tagName}[href='${reference.value}']`).length &&
!head.querySelectorAll(`${tagName}[src='${reference.value}']`).length &&

{code}
In the second case, the browser does internal normalization for the match!

 


was (Author: werpu):
Found the issue the doubleInclude filter is failing because it searchs for an 
exact match:

 
{code:javascript}
var doubleExistsFilter = function(item)  {

...

 var links = document.head.getElementsByTagName("link");
                    for(var cnt = 0; cnt < links.length; cnt++) {
                        if(href && links[cnt].getAttribute("href") == href)

{                             return false;                         }

else if(!href && links[cnt].innerText == content) \{                            
 return false;                         }

                    }

}

 

links[cnt].getAttribute("href")
'http://localhost:8080/d1674ff9-e45d-46c3-9c33-f093c2e486c5/jakarta.faces.resource/addedViaInclude.css.xhtml?ln=spec1423'
href
'/d1674ff9-e45d-46c3-9c33-f093c2e486c5/jakarta.faces.resource/addedViaInclude.css.xhtml?ln=spec1423'

 

{code}
The filter always indicates the element does not exist because the match always 
will return false, due to having the url prefixed and in the second case only 
the path without url.

The reason why this works in the new code is, because we use a pattern query 
(which I cannot use in the old one, due to legacy browser support:

 

{code:javascript}

function resourceIsNew(element: DomQuery) {

...

return !head.querySelectorAll(`${tagName}[href='${reference.value}']`).length &&
!head.querySelectorAll(`${tagName}[src='${reference.value}']`).length &&

{code}

 

> TCK-Spec1423 fails on codebase
> ------------------------------
>
>                 Key: MYFACES-4532
>                 URL: https://issues.apache.org/jira/browse/MYFACES-4532
>             Project: MyFaces Core
>          Issue Type: Task
>    Affects Versions: 3.0.1, 2.3.10, 2.3-next-M7, 4.0.0-RC2
>            Reporter: Werner Punz
>            Assignee: Werner Punz
>            Priority: Minor
>             Fix For: 3.0.3, 2.3-next-M8, 4.0.0-RC3
>
>         Attachments: image-2023-01-13-10-32-20-321.png, 
> image-2023-01-13-10-34-43-383.png
>
>
> See als comments in https://issues.apache.org/jira/browse/MYFACES-4531
>  
> The issue is that every time one of the test buttons is pressed a resource 
> response is issued
> and the resource is reappended.
> Per spec there is no double resource check on the client side, so I did not 
> implement it, the RI however seems to have something in place.
> Server side implementation would be preferrable for this case, but I for now 
> will add a client side fix.
>  
> The easiest way to replicate it is to use my tckworkbench project on:
> [https://github.com/werpu/tckworkbench]
>  



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to