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

DOM Exception 18 on navigate() in Safari 9.1 #4029

Closed
zowers opened this issue May 13, 2016 · 11 comments
Closed

DOM Exception 18 on navigate() in Safari 9.1 #4029

zowers opened this issue May 13, 2016 · 11 comments
Labels

Comments

@zowers
Copy link

zowers commented May 13, 2016

SecurityError: DOM Exception 18 is thrown by Safari (iOS and OSX) from the moment pushState() is called 100 times.

https://forums.developer.apple.com/thread/36650
fiddle: https://jsfiddle.net/n3uxkyhr/5/

var TestRouter = Backbone.Router.extend( {
    initialize: function() {
        this.route("/test/:id", function( id ) { console.log("test" + id) });
    }
} );
var router = new TestRouter();
Backbone.history.start({pushState: true});

try {
  for(var i = 0; i < 200; i++ ) {
      router.navigate("/test/"+i);
    }
    alert("passed, i = " + i);
} catch( e ) {
    var msg = "failed on i " + i + " with error: " + e + "\nStack: " + e.stack;
  console.error( e, msg );
  alert(msg);
}

fails with:

failed on i 100 with error: Error: SecurityError: DOM Exception 18
Stack: pushState@[native code]
navigate@https://cdnjs.cloudflare.com/ajax/libs/backbone.js/1.3.3/backbone.js:1823:69
navigate@https://cdnjs.cloudflare.com/ajax/libs/backbone.js/1.3.3/backbone.js:1522:32
global code@https://fiddle.jshell.net/n3uxkyhr/6/show/:63:22"
global code — show:68
@paulfalgout
Copy link
Collaborator

The apple developer forum link you posted seems to suggest this issue is with safari. What do you want backbone to do about this?

@zowers
Copy link
Author

zowers commented May 14, 2016

backbone needs to workaround the browser bug.

@megawac
Copy link
Collaborator

megawac commented May 17, 2016

Is there a workaround you're aware of @zowers? Does this bug only occur if navigate is called 100 times synchronously or will it happen if its called 100 times in general?

@zowers
Copy link
Author

zowers commented May 18, 2016

to workaround I had to wrap navigate in a try/catch
in safari 9.1 (latest stable as of today) - it 100 times total
in safari 9.1.1 developer preview - it's 100 times in 30 seconds

@zowers
Copy link
Author

zowers commented May 18, 2016

why is it won't fix?
do you say it's acceptable to have a non-working functionality?

@megawac
Copy link
Collaborator

megawac commented May 18, 2016

I placed that there because reading the safari bug I did not see an acceptable solution. Using a try/catch and not changing the route after the 100th change is not acceptable IMO

@jridgewell
Copy link
Collaborator

Using a try/catch and not changing the route after the 100th change is not acceptable IMO

Agreed. That's a silent failure, which is worse than the current behavior.

@zowers
Copy link
Author

zowers commented May 18, 2016

probably navigate should fallback to hash in case of error

@zowers
Copy link
Author

zowers commented May 19, 2016

today safari 9.1.1 with the fix got released
in safari safari 9.1.1 history.pushState() fails only if called 100 times in 30 seconds

@zowers
Copy link
Author

zowers commented May 19, 2016

closed? hoping people will get the update soon?

@jridgewell
Copy link
Collaborator

This is a bug in Safari without much we can do. Given that 9.1 has only been out for 2 months, I think we're safe not doing anything and letting people update.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

5 participants