-
Notifications
You must be signed in to change notification settings - Fork 2.4k
Conversation
Do you have a test case that demonstrates the problem you are trying to fix? In your case, what is the url being calculated? |
…g always returned false... Fixed.
Ok. i've a test that demonstrates the problem: With the current version of JQM, when an original base tag is defined in HTML, it doesnt works: With my version, it works: Others tests (it still works when no original base tag is defined!) are available here: |
Wow looking at your patch forced me to look at the baseTagTest() implementation. I really messed that one up cause this all used to work. Anyways, the current incarnation of baseTagTest() doesn't even test the dynamic changing of a base tag so I re-wrote it so it did. It looks like this:
So now my question, is why was it necessary to change the getClosestBaseUrl() to check $.support.dynamicBaseTag? |
It's not to check $.support.dynamicBaseTag. It's because, without this change, when an original base tag is defined in HTML, getClosestBaseUrl() doesn't return the right url... |
Ok, so I had some time today to look into this more. There are actually several problems.
The baseTagTest() re-write I posted a few comments back addresses both #1 and #2. @jguyomard attempted to fix #3 by forcing the URL to be used to be the base if $.support.dynamicBaseTag was true, but the fix assumes that all external documents will have the same base, when in fact they won't, especially in the case where no base tag is ever used, but the platform/device actually supports dynamicBaseTag. #4 is a known issue. We don't support the loading of external pages that specify their own tag, which I hope to fix during the 1.x timeframe. I believe there is an actual issue already reported about it. I think a better interim fix for #3, until we can add support for #4, is to modify getClosestBaseUrl() to do this check:
That way we can get the case where the application document contains a and the external pages don't, working. The alternative, would be to assume that all external documents pulled in are assumed to have the exact same path which I think @jguyomard was thinking and instead check:
@toddparker and @johnbender, thoughts? |
I don't think it's safe to assume that both have the same base tag for #3 so we should try to make this as robust as we can. |
Makes sense. So you recommend fixing 1-3 sooner, but try to tackle 4 soon? |
Yes. |
Hi, @jblas :
Ok, you're right, my solution doesn't work if no base tag is ever defined in HTML, and if all external documents don't have the same base... I made a test here: I made others tests, your solution works when no base tag is defined in HTML: ...but does't work when a base tag is defined (link in ajax.htm doesn't work): |
I made an other commit. Now, it works when an original base tag is defined in HTML AND it works if no base tag is ever defined in HTML:
All my tests are here: http://labs.julien.guyomard.org/jqm/base/ |
Arf, my solution doesn't work with images contained in page loaded by ajax... (when an original base tag is defined in HTML and src attribute is relative)... Another solution is to convert all relative url to absolute url, when a page is loaded by ajax. Something like that in if ( $.support.dynamicBaseTag && $base.length ) {
page.find( "[src], link[href], a[rel='external'], :jqmData(ajax='false'), a[target]" ).each(function() {
var thisAttr = $( this ).is( '[href]' ) ? 'href' : $(this).is('[src]') ? 'src' : 'action';
var thisUrl = $( this ).attr( thisAttr );
if( !/^https?:/.test( thisUrl ) ) {
$( this ).attr( thisAttr, documentBase.hrefNoHash + thisUrl );
}
});
} Seems to work everywhere... |
Hum, ok ; i've a better solution to correct the problem mentioned in my previous reply. In if ( base ) {
base.set( fileUrl );
} So, you modify original base tag with the url of the page loaded with by ajax... |
@@ -761,7 +761,7 @@ define( [ | |||
} | |||
|
|||
if ( base ) { | |||
base.set( fileUrl ); | |||
//base.set( fileUrl ); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This makes the whole branch a no-op. If that's the intention maybe just remove it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If I'm not mistaken, that line is necessary to make sure that images within the page load properly. The problem here is that I think the base should be set to the fileUrl, or in the case where the page we just loaded contains a base tag, it should be set to that base tag path.
Is this something we should convert into an issue and take it from there internally? It seems like there's a lot to consider. Otherwise I'll have to defer to you on merging this in. |
Yes, there should definitely be an issue filed for this stuff, with the points I mentioned above with what is wrong today. I'm a bit slammed at the moment, otherwise I would jump on looking at this. |
There are a whole host of issues at play here and we'll probably end up handling this internally as a result. Thanks for your pull request, we wouldn't have gotten this far without it! See #3978. |
Ajax didn't work when an original "base" tag is defined in HTML... This patch fixes this, when $.support.dynamicBaseTag is set to true.