Giter Club home page Giter Club logo

Comments (5)

bluetwin avatar bluetwin commented on September 7, 2024

Its only a deprecation warning, but problematic to fix:

"Chrome 22 (current Canary) deprecates this feature by replacing it with sending ArrayBufferViews instead. JS Typed Arrays are just special ArrayBufferViews, so all this really means is that you can now send a typed array directly across the wire without touching its underlying buffer. This change is in match step with the recent updates to the XMLHttpRequest2 spec."

http://updates.html5rocks.com/2012/07/Arrived-xhr-send-ArrayBufferViews

try {
    if (XMLHttpRequest.prototype.sendAsBinary) {
        return;
    }
    XMLHttpRequest.prototype.sendAsBinary = function(datastr) {
      function byteValue(x) {
        return x.charCodeAt(0) & 0xff;
      }
      var ords = Array.prototype.map.call(datastr, byteValue);
      var ui8a = new Uint8Array(ords);
      this.send(ui8a.buffer);
    };
  } catch (e) {}

So instead of sending an ArrayBuffer on line 476

this.send(ui8a.buffer);

Remove the .buffer and send the typed array itself:

this.send(ui8a);

it removes the warning, but there isn't a check for older webkits that don't support sending ArrayBufferView..
possible solutions:

  1. check for browser and version(problematic)
  2. check on load if XMLHttpRequest.send accepts(ArrayBufferView)

Tested on:
Chrome Version 22.0.1229.94 m
Firefox 16.0.1

from jquery-filedrop.

nodesocket avatar nodesocket commented on September 7, 2024

Would a try() catch() around it work?

try {
    this.send(ui8a);
} catch(error) {
    this.send(ui8a.buffer);
}

from jquery-filedrop.

bluetwin avatar bluetwin commented on September 7, 2024

There isn't an error thrown but a console.warn() posted so nothing to catch..
Tested the removed '.buffer' code on Chrome 21 on OsX Lion and it silently failed.
No data was sent to the server.

Looks like it should be left in until the new W3C is widely accepted and you can rule out the older browser versions.
http://dvcs.w3.org/hg/xhr/raw-file/tip/Overview.html#dom-xmlhttprequest-send

There's probably a work around and it will haunt me for weeks...just short on time with current projects.

from jquery-filedrop.

julien-c avatar julien-c commented on September 7, 2024

Impacted by this as well... Is there a Modernizr feature detection for this?

from jquery-filedrop.

npetrovski avatar npetrovski commented on September 7, 2024

Not sure why, probably Array.prototype.map way already re-defined and extended by someone of the plugins I have already added on my page, but my Firefox 41.0.1 was blocking at:

var ords = Array.prototype.map.call(datastr, byteValue);

, that's why I modified the whole method to:

    XMLHttpRequest.prototype.sendAsBinary = function(datastr) {
        var nBytes = datastr.length, ui8a = new Uint8Array(nBytes);
        for (var nIdx = 0; nIdx < nBytes; nIdx++) {
          ui8a[nIdx] = datastr.charCodeAt(nIdx) & 0xff;
        }

      if ('ArrayBufferView' in window)
        this.send(ui8a);
      else
        this.send(ui8a.buffer);
    };

and this worked for me.

from jquery-filedrop.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.