Browse Source

keep url in ajaxfeed event source object, fixes #3845

Adam Shaw 8 năm trước cách đây
mục cha
commit
8d8e9d6761

+ 7 - 5
src/models/event-source/JsonFeedEventSource.js

@@ -2,10 +2,11 @@
 var JsonFeedEventSource = EventSource.extend({
 
 	// these props must all be manually set before calling fetch
+	url: null,
 	startParam: null,
 	endParam: null,
 	timezoneParam: null,
-	ajaxSettings: null,
+	ajaxSettings: null, // does not include url
 
 
 	fetch: function(start, end, timezone) {
@@ -23,9 +24,9 @@ var JsonFeedEventSource = EventSource.extend({
 
 		return Promise.construct(function(onResolve, onReject) {
 			$.ajax($.extend(
-				{}, // avoid mutation
+				{ url: this.url },
 				JsonFeedEventSource.AJAX_DEFAULTS,
-				ajaxSettings, // should have a `url`
+				ajaxSettings,
 				{
 					data: requestParams,
 					success: function(rawEventDefs) {
@@ -104,7 +105,7 @@ var JsonFeedEventSource = EventSource.extend({
 
 
 	getPrimitive: function() {
-		return this.ajaxSettings.url;
+		return this.url;
 	},
 
 
@@ -125,6 +126,7 @@ JsonFeedEventSource.AJAX_DEFAULTS = {
 
 JsonFeedEventSource.allowRawProps({
 	// automatically transfer (true)...
+	url: true,
 	startParam: true,
 	endParam: true,
 	timezoneParam: true
@@ -139,7 +141,7 @@ JsonFeedEventSource.parse = function(rawInput, calendar) {
 		rawProps = rawInput;
 	}
 	else if (typeof rawInput === 'string') { // short form
-		rawProps = { url: rawInput }; // will end up in ajaxSettings
+		rawProps = { url: rawInput };
 	}
 
 	if (rawProps) {

+ 12 - 0
tests/legacy/events-json-feed.js

@@ -134,4 +134,16 @@ describe('events as a json feed', function() {
 		});
 	});
 
+	it('has and Event Source object with certain props', function() {
+		var url = 'my-feed.php';
+		var source;
+
+		initCalendar({
+			events: { url: url }
+		});
+
+		source = currentCalendar.getEventSources()[0];
+		expect(source.url).toBe(url);
+	});
+
 });