Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Option to use main window window.history #444

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/client/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,8 @@ spf.config.defaults = {
'navigate-lifetime': 24 * 60 * 60 * 1000, // 1 day session lifetime (ms).
'reload-identifier': null, // Always a param, no '?' needed.
'request-timeout': 0, // No request timeout.
'url-identifier': '?spf=__type__'
'url-identifier': '?spf=__type__',
'use-iframe': true
};


Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

f

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hmm

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hello

Expand Down
23 changes: 16 additions & 7 deletions src/client/history/history.js
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,7 @@ spf.history.doPushState_ = function(data, title, opt_url) {
// This check makes sure that pushState is a function when called to
// avoid js errors and a state where the back arrow stops working.
var iframe = spf.history.getIframe();
var pushState = iframe.contentWindow.history.pushState;
var pushState = iframe.history.pushState;
if (typeof pushState == 'function') {
pushState.call(window.history, data, title, opt_url);
} else {
Expand All @@ -282,7 +282,7 @@ spf.history.doPushState_ = function(data, title, opt_url) {
*/
spf.history.doReplaceState_ = function(data, title, opt_url) {
var iframe = spf.history.getIframe();
var replaceState = iframe.contentWindow.history.replaceState;
var replaceState = iframe.history.replaceState;
if (typeof replaceState == 'function') {
replaceState.call(window.history, data, title, opt_url);
} else {
Expand All @@ -292,12 +292,21 @@ spf.history.doReplaceState_ = function(data, title, opt_url) {


/**
* @return {!HTMLIFrameElement} The history iframe.
* @return {!Window} The history iframe.
*/
spf.history.getIframe = function() {
var frame = document.getElementById('history-iframe');
if (!frame) {
frame = spf.dom.createIframe('history-iframe');
var frame = null;
if (spf.config.get('use-iframe')) {
frame = document.getElementById('history-iframe');

if (!frame) {
frame = spf.dom.createIframe('history-iframe');
}

frame = frame.contentWindow;
} else {
frame = window
}
return /** @type {!HTMLIFrameElement} */ (frame);

return /** @type {!Window} */ (frame);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ff

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok

};
2 changes: 1 addition & 1 deletion src/client/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ spf.main.init = function(opt_config) {
*/
spf.main.canInit_ = function() {
return !!(typeof window.history.pushState == 'function' ||
spf.history.getIframe().contentWindow.history.pushState);
spf.history.getIframe().history.pushState);
};


Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

w

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nah

Expand Down