Skip to content

Commit 30e64a9

Browse files
HeroProtagonistkamilogorek
authored andcommitted
Factor out history replacement function
1 parent 1650da7 commit 30e64a9

File tree

1 file changed

+16
-19
lines changed

1 file changed

+16
-19
lines changed

src/raven.js

Lines changed: 16 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1285,26 +1285,23 @@ Raven.prototype = {
12851285
}
12861286
};
12871287

1288-
fill(
1289-
history,
1290-
'pushState',
1291-
function(origPushState) {
1292-
// note history.pushState.length is 0; intentionally not declaring
1293-
// params to preserve 0 arity
1294-
return function(/* state, title, url */) {
1295-
var url = arguments.length > 2 ? arguments[2] : undefined;
1296-
1297-
// url argument is optional
1298-
if (url) {
1299-
// coerce to string (this is what pushState does)
1300-
self._captureUrlChange(self._lastHref, url + '');
1301-
}
1288+
var historyReplacementFunction = function(origHistFunction) {
1289+
// note history.pushState.length is 0; intentionally not declaring
1290+
// params to preserve 0 arity
1291+
return function(/* state, title, url */) {
1292+
var url = arguments.length > 2 ? arguments[2] : undefined;
1293+
1294+
// url argument is optional
1295+
if (url) {
1296+
// coerce to string (this is what pushState does)
1297+
self._captureUrlChange(self._lastHref, url + '');
1298+
}
13021299

1303-
return origPushState.apply(this, arguments);
1304-
};
1305-
},
1306-
wrappedBuiltIns
1307-
);
1300+
return origHistFunction.apply(this, arguments);
1301+
};
1302+
};
1303+
1304+
fill(history, 'pushState', historyReplacementFunction, wrappedBuiltIns);
13081305
}
13091306

13101307
if (autoBreadcrumbs.console && 'console' in _window && console.log) {

0 commit comments

Comments
 (0)