From 55de6653a59c6c0bf62e3301d8cd3ff0c7fdd063 Mon Sep 17 00:00:00 2001 From: ChaominRuan Date: Wed, 2 Aug 2023 17:57:27 +0800 Subject: [PATCH 1/2] fix(copy-paste): fix default sequence flow default propertie are not enumerable --- lib/features/copy-paste/BpmnCopyPaste.js | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/lib/features/copy-paste/BpmnCopyPaste.js b/lib/features/copy-paste/BpmnCopyPaste.js index 194c8ec359..2927762bff 100644 --- a/lib/features/copy-paste/BpmnCopyPaste.js +++ b/lib/features/copy-paste/BpmnCopyPaste.js @@ -40,8 +40,9 @@ var LOW_PRIORITY = 750; * @param {BpmnFactory} bpmnFactory * @param {EventBus} eventBus * @param {ModdleCopy} moddleCopy + * @param {Moddle} moddle */ -export default function BpmnCopyPaste(bpmnFactory, eventBus, moddleCopy) { +export default function BpmnCopyPaste(bpmnFactory, eventBus, moddleCopy, moddle) { function copy(bo, clone) { var targetBo = bpmnFactory.create(bo.$type); @@ -105,10 +106,18 @@ export default function BpmnCopyPaste(bpmnFactory, eventBus, moddleCopy) { return omit(references, reduce(references, function(array, reference, key) { var element = reference.element, - property = reference.property; + property = reference.property, + propertyDescriptor = moddle.getPropertyDescriptor(element, property); + if (key === descriptor.id) { - element[ property ] = businessObject; + + Object.defineProperty(element, property, { + enumerable: !propertyDescriptor.isReference, + value: businessObject, + writable: true, + configurable: true + }); array.push(descriptor.id); } @@ -189,5 +198,6 @@ export default function BpmnCopyPaste(bpmnFactory, eventBus, moddleCopy) { BpmnCopyPaste.$inject = [ 'bpmnFactory', 'eventBus', - 'moddleCopy' + 'moddleCopy', + 'moddle' ]; \ No newline at end of file From a15f5d2cfafbe273b8c27cd5b35b4f7558c22b90 Mon Sep 17 00:00:00 2001 From: ChaominRuan Date: Tue, 8 Aug 2023 20:57:43 +0800 Subject: [PATCH 2/2] fix(copy-paste): add a test to see if the default attribute is enumerable --- test/spec/features/copy-paste/BpmnCopyPasteSpec.js | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/test/spec/features/copy-paste/BpmnCopyPasteSpec.js b/test/spec/features/copy-paste/BpmnCopyPasteSpec.js index 3923348ce1..dbf9c76378 100644 --- a/test/spec/features/copy-paste/BpmnCopyPasteSpec.js +++ b/test/spec/features/copy-paste/BpmnCopyPasteSpec.js @@ -264,11 +264,12 @@ describe('features/copy-paste', function() { expect(conditionalFlow).to.exist; expect(defaultFlow).to.exist; + expect(Object.prototype.propertyIsEnumerable.call(taskBo,'default')).to.be.false; }) ); - it('should copy attacher properties', inject(function(canvas, copyPaste, elementRegistry) { + it('should copy attached properties', inject(function(canvas, copyPaste, elementRegistry) { // given var task = elementRegistry.get('Task_1'), @@ -300,7 +301,7 @@ describe('features/copy-paste', function() { })); - it('should copy loop characteristics porperties', + it('should copy loop characteristics properties', inject(function(canvas, copyPaste, elementRegistry, modeling) { // given @@ -375,7 +376,7 @@ describe('features/copy-paste', function() { it('should copy label', inject( - function(canvas, copyPaste, elementRegistry, modeling) { + function(canvas, copyPaste, elementRegistry) { // given var startEvent = elementRegistry.get('StartEvent_1'),