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

Safari 6 bug: "SYNTAX_ERR: DOM Exception 12: An invalid or illegal string was specified." #11

Closed
aseemk opened this issue Feb 19, 2014 · 7 comments

Comments

@aseemk
Copy link

aseemk commented Feb 19, 2014

Hi there,

Great work on xhook and xdomain. Really like the idea, and we're switching to it in an app I work on, to get rid of annoying CORS pre-flight requests for our JSON API.

Unfortunately, the switch has killed our app in Safari 6 with the following error:

SYNTAX_ERR: DOM Exception 12: An invalid or illegal string was specified.

I've debugged this error to this part of xhook:

    send = function() {
      var header, value, _j, _len1, _ref1, _ref2;
      transiting = true;
      xhr.open(request.method, request.url, true, request.user, request.pass);
      _ref1 = ['type', 'timeout'];
      for (_j = 0, _len1 = _ref1.length; _j < _len1; _j++) {
        k = _ref1[_j];
        modk = k === "type" ? "responseType" : k;
        xhr[modk] = request[k];    // <------------ this line
      }
      _ref2 = request.headers;
      for (header in _ref2) {
        value = _ref2[header];
        xhr.setRequestHeader(header, value);
      }
      if (request.body instanceof window[FormData]) {
        request.body = request.body.fd;
      }
      xhr.send(request.body);
    };

k is indeed "type", but request.type is undefined, and Safari 6 rejects setting xhr.responseType to undefined.

It seems to work fine in Safari 7 (Mavericks), iOS 7 Mobile Safari, and Chrome.

We're on the latest xdomain 0.6.1 which contains xhook 1.1.4. We're using xdomain with jQuery 1.10, but not making Ajax calls directly; we're a Backbone app, so it's doing that automatically / under the hood.

Any ideas? Thanks for the help!

@jpillora
Copy link
Owner

Will fix now. Thanks for the debugging effort :)

On Thursday, February 20, 2014, Aseem Kishore notifications@github.com
wrote:

Hi there,

Great work on xhook and xdomain. Really like the idea, and we're switching
to it in an app I work on, to get rid of annoying CORS pre-flight requests
for our JSON API.

Unfortunately, the switch has killed our app in Safari 6 with the
following error:

SYNTAX_ERR: DOM Exception 12: An invalid or illegal string was specified.

I've debugged this error to this part of xhook:

send = function() {
  var header, value, _j, _len1, _ref1, _ref2;
  transiting = true;
  xhr.open(request.method, request.url, true, request.user, request.pass);
  _ref1 = ['type', 'timeout'];
  for (_j = 0, _len1 = _ref1.length; _j < _len1; _j++) {
    k = _ref1[_j];
    modk = k === "type" ? "responseType" : k;
    xhr[modk] = request[k];    // <------------ this line
  }
  _ref2 = request.headers;
  for (header in _ref2) {
    value = _ref2[header];
    xhr.setRequestHeader(header, value);
  }
  if (request.body instanceof window[FormData]) {
    request.body = request.body.fd;
  }
  xhr.send(request.body);
};

k is indeed "type", but request.type is undefined, and Safari 6 rejects
setting xhr.responseType to undefined.

It seems to work fine in Safari 7 (Mavericks), iOS 7 Mobile Safari, and
Chrome.

I'm on the latest xdomain 0.6.1 which contains xhook 1.1.4. We're using
xdomain with jQuery 1.10, but not making Ajax calls directly; we're a
Backbone app, so it's doing that automatically / under the hood.

Any ideas? Thanks for the help!

Reply to this email directly or view it on GitHubhttps://github.com//issues/11
.

@aseemk
Copy link
Author

aseemk commented Feb 19, 2014

Great to hear! Thanks for the awesomely fast response too. =)

@aseemk
Copy link
Author

aseemk commented Feb 19, 2014

Thanks for the quick fix! Would you mind posting here whenever a new xdomain is available with this xhook update? Looking forward to it!

@jpillora
Copy link
Owner

Yep no worries, had to run, will work on that soon

On Thu, Feb 20, 2014 at 9:46 AM, Aseem Kishore notifications@github.comwrote:

Thanks for the quick fix! Would you mind posting here whenever a new
xdomain is available with this xhook update? Looking forward to it!

Reply to this email directly or view it on GitHubhttps://github.com//issues/11#issuecomment-35559516
.

@jpillora
Copy link
Owner

fix is up :)

@aseemk
Copy link
Author

aseemk commented Feb 20, 2014

Seems to work great. Thank you!

@jpillora
Copy link
Owner

Good to hear :)

On Thu, Feb 20, 2014 at 4:27 PM, Aseem Kishore notifications@github.comwrote:

Seems to work great. Thank you!

Reply to this email directly or view it on GitHubhttps://github.com//issues/11#issuecomment-35590459
.

gasi pushed a commit to WeTransferArchive/xhook that referenced this issue Apr 30, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants