@@ -45,20 +45,22 @@ var CUSTOM_PROPERTIES = [
4545 'isInterrupting'
4646] ;
4747
48-
49- function toggeling ( element , target ) {
48+ /**
49+ * Check if element should be collapsed or expanded.
50+ */
51+ function shouldToggleCollapsed ( element , targetElement ) {
5052
5153 var oldCollapsed = (
5254 element && has ( element , 'collapsed' ) ? element . collapsed : ! isExpanded ( element )
5355 ) ;
5456
5557 var targetCollapsed ;
5658
57- if ( target && ( has ( target , 'collapsed' ) || has ( target , 'isExpanded' ) ) ) {
59+ if ( targetElement && ( has ( targetElement , 'collapsed' ) || has ( targetElement , 'isExpanded' ) ) ) {
5860
5961 // property is explicitly set so use it
6062 targetCollapsed = (
61- has ( target , 'collapsed' ) ? target . collapsed : ! target . isExpanded
63+ has ( targetElement , 'collapsed' ) ? targetElement . collapsed : ! targetElement . isExpanded
6264 ) ;
6365 } else {
6466
@@ -67,15 +69,13 @@ function toggeling(element, target) {
6769 }
6870
6971 if ( oldCollapsed !== targetCollapsed ) {
70- element . collapsed = oldCollapsed ;
7172 return true ;
7273 }
7374
7475 return false ;
7576}
7677
7778
78-
7979/**
8080 * This module takes care of replacing BPMN elements
8181 */
@@ -106,15 +106,13 @@ export default function BpmnReplace(
106106 var type = target . type ,
107107 oldBusinessObject = element . businessObject ;
108108
109- if ( isSubProcess ( oldBusinessObject ) ) {
110- if ( type === 'bpmn:SubProcess' ) {
111- if ( toggeling ( element , target ) ) {
109+ if ( isSubProcess ( oldBusinessObject ) && type === 'bpmn:SubProcess' ) {
110+ if ( shouldToggleCollapsed ( element , target ) ) {
112111
113- // expanding or collapsing process
114- modeling . toggleCollapse ( element ) ;
112+ // expanding or collapsing process
113+ modeling . toggleCollapse ( element ) ;
115114
116- return element ;
117- }
115+ return element ;
118116 }
119117 }
120118
0 commit comments