Skip to content

Commit

Permalink
Fixes to fallback scoping, streamCache[options.label].options; New un…
Browse files Browse the repository at this point in the history
…it tests - 100% pass
  • Loading branch information
rwaldron committed Aug 26, 2010
1 parent 2913331 commit 5f8e083
Showing 1 changed file with 14 additions and 7 deletions.
21 changes: 14 additions & 7 deletions jquery.eventsource.js
Original file line number Diff line number Diff line change
Expand Up @@ -110,17 +110,21 @@


this['label'] = options.label;
options.open.call(this);
streamCache[options.label].options.open.call(this);
}
},
success: function ( data ) {

if ( data.indexOf('data: ') === -1 ) {
return false;
}

var parsedData = [],
streamData = $.map( data.split("\n"), function (sdata, i) {
if ( sdata ) {
return sdata;
}
});
if ( sdata ) {
return sdata;
}
});

if ( $.isArray(streamData) ) {

Expand All @@ -143,7 +147,7 @@

this['label'] = options.label;

options.message.call(this, parsedData[0] ? parsedData[0] : null, {
streamCache[options.label].options.message.call(this, parsedData[0] ? parsedData[0] : null, {
data: parsedData,
lastEventId: streamCache[options.label].lastEventId
});
Expand Down Expand Up @@ -219,7 +223,10 @@
_options = $.extend({}, streamSrcSettings, options);

// CREATE EMPTY OBJECT IN `streamCache`
streamCache[_options.label] = {};
streamCache[_options.label] = {
options: _options
};


// DETERMINE AND DECLARE `stream`
stream = !isNative ?
Expand Down

0 comments on commit 5f8e083

Please sign in to comment.