Update vendors.

Former-commit-id: d1dd2ecf337cf8cda71e0da2af0647813b8de24a
This commit is contained in:
John-David Dalton
2012-08-02 00:32:15 -07:00
parent 5a9a18501d
commit 4f688028ad
3 changed files with 122 additions and 67 deletions

View File

@@ -134,6 +134,9 @@
rest = []; rest = [];
events = events.split(eventSplitter); events = events.split(eventSplitter);
// Fill up `rest` with the callback arguments. Since we're only copying
// the tail of `arguments`, a loop is much faster than Array#slice.
for (i = 1, length = arguments.length; i < length; i++) { for (i = 1, length = arguments.length; i < length; i++) {
rest[i - 1] = arguments[i]; rest[i - 1] = arguments[i];
} }
@@ -1023,6 +1026,9 @@
var docMode = document.documentMode; var docMode = document.documentMode;
var oldIE = (isExplorer.exec(navigator.userAgent.toLowerCase()) && (!docMode || docMode <= 7)); var oldIE = (isExplorer.exec(navigator.userAgent.toLowerCase()) && (!docMode || docMode <= 7));
// Normalize root to always include trailing slash
if (!trailingSlash.test(this.options.root)) this.options.root += '/';
if (oldIE && this._wantsHashChange) { if (oldIE && this._wantsHashChange) {
this.iframe = Backbone.$('<iframe src="javascript:0" tabindex="-1" />').hide().appendTo('body')[0].contentWindow; this.iframe = Backbone.$('<iframe src="javascript:0" tabindex="-1" />').hide().appendTo('body')[0].contentWindow;
this.navigate(fragment); this.navigate(fragment);
@@ -1042,7 +1048,7 @@
// opened by a non-pushState browser. // opened by a non-pushState browser.
this.fragment = fragment; this.fragment = fragment;
var loc = this.location; var loc = this.location;
var atRoot = (loc.pathname === this.options.root) && !loc.search; var atRoot = (loc.pathname.replace(/[^/]$/, '$&/') === this.options.root) && !loc.search;
// If we've started off with a route from a `pushState`-enabled browser, // If we've started off with a route from a `pushState`-enabled browser,
// but we're currently in a browser that doesn't support it... // but we're currently in a browser that doesn't support it...

View File

@@ -20,9 +20,11 @@ $(document).ready(function() {
_.extend(this, _.pick($('<a></a>', {href: href})[0], _.extend(this, _.pick($('<a></a>', {href: href})[0],
'href', 'href',
'hash', 'hash',
'host',
'search', 'search',
'fragment', 'fragment',
'pathname' 'pathname',
'protocol'
)); ));
// In IE, anchor.pathname does not contain a leading slash though // In IE, anchor.pathname does not contain a leading slash though
// window.location.pathname does. // window.location.pathname does.
@@ -318,4 +320,52 @@ $(document).ready(function() {
strictEqual(Backbone.history.fragment, 'x'); strictEqual(Backbone.history.fragment, 'x');
}); });
test("Router: Normalize root.", 1, function() {
Backbone.history.stop();
location.replace('http://example.com/root');
Backbone.history = new Backbone.History({
location: location,
history: {
pushState: function(state, title, url) {
strictEqual(url, '/root/fragment');
}
}
});
Backbone.history.start({
pushState: true,
root: '/root',
hashChange: false
});
Backbone.history.navigate('fragment');
});
test("Router: Normalize root.", 1, function() {
Backbone.history.stop();
location.replace('http://example.com/root#fragment');
Backbone.history = new Backbone.History({
location: location,
history: {
pushState: function(state, title, url) {},
replaceState: function(state, title, url) {
strictEqual(url, 'http://example.com/root/fragment');
}
}
});
Backbone.history.start({
pushState: true,
root: '/root'
});
});
test("Router: Normalize root.", 1, function() {
Backbone.history.stop();
location.replace('http://example.com/root');
Backbone.history = new Backbone.History({location: location});
Backbone.history.loadUrl = function() { ok(true); };
Backbone.history.start({
pushState: true,
root: '/root'
});
});
}); });

View File

@@ -2410,8 +2410,7 @@
'teardown': getSource(bench.teardown, preprocess('m$.teardown()')) 'teardown': getSource(bench.teardown, preprocess('m$.teardown()'))
}; };
var compiled = bench.compiled, var count = bench.count = clone.count,
count = bench.count = clone.count,
decompilable = support.decompilation || stringable, decompilable = support.decompilation || stringable,
id = bench.id, id = bench.id,
isEmpty = !(source.fn || stringable), isEmpty = !(source.fn || stringable),
@@ -2433,9 +2432,10 @@
} }
} }
if (!compiled) { // Compile in setup/teardown functions and the test loop.
// compile in setup/teardown functions and the test loop // Create a new compiled test, instead of using the cached `bench.compiled`,
compiled = bench.compiled = createFunction(preprocess('t$'), interpolate( // to avoid potential engine optimizations enabled over the life of the test.
var compiled = bench.compiled = createFunction(preprocess('t$'), interpolate(
preprocess(deferred preprocess(deferred
? 'var d$=this,#{fnArg}=d$,m$=d$.benchmark._original,f$=m$.fn,su$=m$.setup,td$=m$.teardown;' + ? 'var d$=this,#{fnArg}=d$,m$=d$.benchmark._original,f$=m$.fn,su$=m$.setup,td$=m$.teardown;' +
// when `deferred.cycles` is `0` then... // when `deferred.cycles` is `0` then...
@@ -2506,7 +2506,6 @@
} }
} }
} }
}
// assign `compiled` to `clone` before calling in case a deferred benchmark // assign `compiled` to `clone` before calling in case a deferred benchmark
// immediately calls `deferred.resolve()` // immediately calls `deferred.resolve()`
clone.compiled = compiled; clone.compiled = compiled;