From debf6b6622b387f28b4d01fd93a26fd6236de040 Mon Sep 17 00:00:00 2001 From: Sascha Gehlich Date: Mon, 10 Jan 2011 09:50:59 +0100 Subject: [PATCH] fixed jsonp-polling .insertBefore() call --- lib/transports/jsonp-polling.js | 6 +++--- socket.io.js | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/lib/transports/jsonp-polling.js b/lib/transports/jsonp-polling.js index 33b78ac8d..dfd1e03c5 100644 --- a/lib/transports/jsonp-polling.js +++ b/lib/transports/jsonp-polling.js @@ -10,7 +10,7 @@ io.JSONP = []; JSONPPolling = io.Transport['jsonp-polling'] = function(){ io.Transport.XHR.apply(this, arguments); - this._insertAt = document.getElementsByTagName('script')[0]; + this._insertAt = document.getElementsByTagName('head')[0]; this._index = io.JSONP.length; io.JSONP.push(this); }; @@ -35,7 +35,7 @@ JSONPPolling.prototype._send = function(data){ form.action = this._prepareUrl() + '/' + (+new Date) + '/' + this._index; area.name = 'data'; form.appendChild(area); - this._insertAt.parentNode.insertBefore(form, this._insertAt); + this._insertAt.insertBefore(form, null); document.body.appendChild(form); this._form = form; @@ -97,7 +97,7 @@ JSONPPolling.prototype._get = function(){ script.onerror = function(){ self._onDisconnect(); }; - this._insertAt.parentNode.insertBefore(script, this._insertAt); + this._insertAt.insertBefore(script, null); this._script = script; }; diff --git a/socket.io.js b/socket.io.js index 5d685422f..e7b11d064 100644 --- a/socket.io.js +++ b/socket.io.js @@ -666,7 +666,7 @@ io.JSONP = []; JSONPPolling = io.Transport['jsonp-polling'] = function(){ io.Transport.XHR.apply(this, arguments); - this._insertAt = document.getElementsByTagName('script')[0]; + this._insertAt = document.getElementsByTagName('head')[0]; this._index = io.JSONP.length; io.JSONP.push(this); }; @@ -691,7 +691,7 @@ JSONPPolling.prototype._send = function(data){ form.action = this._prepareUrl() + '/' + (+new Date) + '/' + this._index; area.name = 'data'; form.appendChild(area); - this._insertAt.parentNode.insertBefore(form, this._insertAt); + this._insertAt.insertBefore(form, null); document.body.appendChild(form); this._form = form; @@ -753,7 +753,7 @@ JSONPPolling.prototype._get = function(){ script.onerror = function(){ self._onDisconnect(); }; - this._insertAt.parentNode.insertBefore(script, this._insertAt); + this._insertAt.insertBefore(script, null); this._script = script; };