Querystrings containing "http" in the middle will load synchronously #276

Closed
wants to merge 50 commits into
from

Conversation

Projects
None yet
10 participants
Contributor

JeffreyWay commented Oct 21, 2010

So, when working on a mobile project, I accidentally forgot to urlencode one of the values in the querystring. So the local url ended up being something like: somePage.php?bla=bla&path=http://...

The problem is that jQuery Mobile seems to test if "http" exists at all in the url. If it does, it's considered an external link, and loads synchronously.

Granted, this was an error on my part. Technically, 'http://' shouldn't exist in the querystring. But, assuming others make the same mistakes, and forget to url encode, the framework should compensate. Ensuring that the value "http://" occurs at the beginning of the string fixes it: ^https?

Very quick video example, if it helps: http://screenr.com/YkD

Contributor

ehynds commented on 538a56c Oct 23, 2010

How forward compatible do you think this will be as triggerHandler is on the 1.5 roadmap for deprecation? http://docs.jquery.com/JQuery_1.5_Roadmap

Contributor

scottjehl replied Oct 23, 2010

good call. not using it anymore. :)

scottjehl and others added some commits Oct 23, 2010

added support for grouped collapsibles that make accordions. Parent e…
…lement just needs a data-role of collapsible-set. Fixes #87, Fixes #178
Removed the ajaxClick function and moved its logic into the live clic…
…k event handler, where it is now refactored and simplified. Thx to Jeffrey Way for ideas that went into this refactor.

Also, clicks that are triggered on anchors will now be able to make a new http request, which improves listview behavior when clicking LIs that resolve to external urls.

Included in commit is a new demo/test page with various link types to make sure they behave as expected.

Fixes #272, Fixes #264
made default breakpoints non-overrideable and exposed function $.mobi…
…le.addResolutionBreakpoints (accepts number or array of numbers) which can be used to add widths to be used in min/max media classes on HTML element.
Contributor

JeffreyWay commented on js/jquery.mobile.js in e736cae Oct 26, 2010

Hmm - would it be better to use the delegate method, so that we're not attaching a listener to every single anchor on the page? I wonder if it'd make any noticeable difference..

Contributor

scottjehl replied Oct 27, 2010

Live uses event delegation. So, only one event binding to document.

Contributor

JeffreyWay replied Oct 27, 2010

Oh, haha. I'd swear I read "bind," instead of "live." Disregard.

Contributor

JeffreyWay commented on js/jquery.mobile.js in e736cae Oct 27, 2010

The second OR part of the regex will match a hash that's anywhere in the href. The caret should be in front. So:
/^\w+:|^#/.test( href )
Or:
/^(\w+:|#)/.test( href )

Owner

jzaefferer replied Oct 27, 2010

If you don't need that group anyway, use a non-capturing group:

/^(:?\w+:|#)/.test( href )
Contributor

JeffreyWay commented on js/jquery.mobile.js in e736cae Oct 27, 2010

Is nullLink being used anywhere else in this script? If so, is there a need to create the variable? Maybe not...
//for links created purely for interaction - ignore
(href === '#') && return false;

Contributor

JeffreyWay commented on js/jquery.mobile.js in e736cae Oct 27, 2010

Can we still use the 'cached' version of $(this)?
changeHashOnSuccess = !$this.is(unHashedSelectors);

Contributor

JeffreyWay commented on js/jquery.mobile.js in e736cae Oct 27, 2010

Saves a few characters.
if ( href.indexOf('/') && href.indexOf('#') !== 0 ) { ...

Contributor

JeffreyWay replied Oct 27, 2010

So, this covers '/somepage.html' and '#somepage.html'. But what about:
some page
Does this need to receive the base url as well?

Contributor

scottjehl replied Oct 27, 2010

unless I'm misunderstanding your question, it's those two types that don't get the relative base, while any others do. Some somepage.html would be covered, ya.

Contributor

JeffreyWay replied Oct 27, 2010

Hey Scott - So odd; I've deleted that comment three times now. Deleted it a few moments after originally posting it last night. Trying it again! UPDATE - must be a Github bug. Every time I delete the thread, and refresh the page, it shows back up again.

Contributor

scottjehl replied Oct 27, 2010

ok - no prob. Changes are in. I'm working on one more - #foo shouldn't go straight to hash change, in case of errors.

Contributor

scottjehl commented on e736cae Oct 27, 2010

thx guys - these updates are rolled in now. http://github.com/jquery/jquery-mobile/commits/master

scottjehl and others added some commits Oct 27, 2010

converted customButton plugin to widget factory (note: this is just t…
…he plugin for native button elements, not to be confused with the buttonMarkup plugin).

renamed method to "button" and updated page.js to match
added check to make sure active link isn't in the new activepage (suc…
…h as when it's appended to the new page for persistence), before removing class

This issue was closed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment