bpmn-moddle
Advanced tools
Comparing version 0.8.0 to 0.8.1
'use strict'; | ||
var ID_PATTERN = /^(.*:)?id$/; | ||
/** | ||
@@ -26,26 +28,29 @@ * Extends the bpmn instance with id support. | ||
model.ids = ids; | ||
var set = model.properties.set; | ||
var ID_PATTERN = /^(.*:)?id$/; | ||
// do not reinitialize setter | ||
// unless it is already initialized | ||
if (!model.ids) { | ||
model.properties.set = function(target, property, value) { | ||
model.properties.set = function(target, property, value) { | ||
// ensure we log used ids once they are assigned | ||
// to model elements | ||
if (ID_PATTERN.test(property)) { | ||
// ensure we log used ids once they are assigned | ||
// to model elements | ||
if (ID_PATTERN.test(property)) { | ||
var assigned = ids.assigned(value); | ||
if (assigned && assigned !== target) { | ||
throw new Error('id <' + value + '> already used'); | ||
var assigned = model.ids.assigned(value); | ||
if (assigned && assigned !== target) { | ||
throw new Error('id <' + value + '> already used'); | ||
} | ||
model.ids.claim(value, target); | ||
} | ||
ids.claim(value, target); | ||
} | ||
set.call(this, target, property, value); | ||
}; | ||
} | ||
set.call(this, target, property, value); | ||
}; | ||
model.ids = ids; | ||
return model; | ||
}; |
{ | ||
"name": "bpmn-moddle", | ||
"version": "0.8.0", | ||
"version": "0.8.1", | ||
"description": "A moddle wrapper for BPMN 2.0", | ||
@@ -5,0 +5,0 @@ "scripts": { |
@@ -25,2 +25,5 @@ 'use strict'; | ||
this.timeout(15000); | ||
it('inputOutput', function(done) { | ||
@@ -27,0 +30,0 @@ |
@@ -59,3 +59,3 @@ 'use strict'; | ||
// when | ||
var serviceTask = moddle.create('bpmn:ServiceTask', { | ||
moddle.create('bpmn:ServiceTask', { | ||
id: 'ServiceTask_1' | ||
@@ -73,4 +73,27 @@ }); | ||
it('should reset and allow reclaim of ids', function() { | ||
// given | ||
var moddle = Helper.createModdle(); | ||
IdSupport.extend(moddle, new Ids()); | ||
moddle.create('bpmn:ServiceTask', { | ||
id: 'ServiceTask_1' | ||
}); | ||
// when | ||
IdSupport.extend(moddle, new Ids()); | ||
// then | ||
// expect id to have been reset | ||
expect(function() { | ||
moddle.create('bpmn:ServiceTask', { | ||
id: 'ServiceTask_1' | ||
}); | ||
}).not.to.throw(); | ||
}); | ||
}); | ||
}); |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
902110
5692