Browse Source

allow removeEvents with _id. fixes #3828

Adam Shaw 8 years ago
parent
commit
3332b0b626
2 changed files with 18 additions and 1 deletions
  1. 2 1
      src/Calendar.events-api.js
  2. 16 0
      tests/legacy/removeEvents.js

+ 2 - 1
src/Calendar.events-api.js

@@ -202,7 +202,8 @@ function filterLegacyEventInstances(legacyEventInstances, legacyQuery) {
 
 		return legacyEventInstances.filter(function(legacyEventInstance) {
 			// soft comparison because id not be normalized to string
-			return legacyEventInstance.id == legacyQuery;
+			return legacyEventInstance.id == legacyQuery ||
+				legacyEventInstance._id === legacyQuery // can specify internal id, but must exactly match
 		});
 	}
 }

+ 16 - 0
tests/legacy/removeEvents.js

@@ -117,6 +117,22 @@ describe('removeEvents', function() {
 		);
 	});
 
+	it('can remove an event with an internal _id', function() {
+		var event;
+
+		initCalendar({
+			defaultDate: '2014-06-24',
+			events: [ { title: 'event0', start: '2014-06-24' } ]
+		});
+
+		event = currentCalendar.clientEvents()[0];
+		expect(typeof event).toBe('object');
+
+		currentCalendar.removeEvents(event._id);
+		expect(
+			currentCalendar.clientEvents().length
+		).toBe(0);
+	});
 
 	// Verifies the actions in removeFunc executed correctly by calling checkFunc.
 	function go(events, removeFunc, checkFunc, doneFunc) {