Skip to content

Commit 5143532

Browse files
committed
remove workaround for removedChild not working earlier
1 parent e04df83 commit 5143532

File tree

3 files changed

+2
-39
lines changed

3 files changed

+2
-39
lines changed

docs/custom_events.md

+2-4
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,9 @@ Fired when a block is added to a script. When a block is moved, it is removed, t
1414

1515
Fired when a block in a script is modified (i.e., it's socket values are changed).
1616

17-
## wb-remove
17+
## wb-removedChild
1818

19-
Fired when a block is removed from a script. Moving a block fires both a remove and an add event.
19+
Fired when a block is removed from a script. Moving a block fires both a removedChild and an add event.
2020

2121
## wb-delete
2222

@@ -45,5 +45,3 @@ Fired when there is a change to one of the state variables (???)
4545
## wb-ready
4646

4747
Fired when all the async components (ide, stage, script) have reported in that they're ready.
48-
49-

js/block.js

-10
Original file line numberDiff line numberDiff line change
@@ -408,13 +408,6 @@ ExpressionProto.detachedCallback = function expressionDetached(){
408408
sib.classList.remove('hide');
409409
});
410410
}
411-
if (this.parent.localName !== 'wb-local'){
412-
var blockParent = dom.closest(this.parent, 'wb-expression, wb-step, wb-context');
413-
// FIXME: Is this needed or was it a workaround for wb-removedChild not firing?
414-
if (blockParent){
415-
Event.trigger(blockParent, 'wb-removedChild', this);
416-
}
417-
}
418411
this.parent = null;
419412
};
420413

@@ -1346,9 +1339,6 @@ Event.registerElementsForAddRemoveEvents(workspace, 'wb-', 'wb-step, wb-context,
13461339
Event.on(workspace, 'editor:wb-added', 'wb-expression', updateVariableType);
13471340
Event.on(workspace, 'editor:wb-added', 'wb-context, wb-step', uniquifyVariableNames);
13481341
Event.on(document.body, 'editor:wb-cloned', '[fn="getVariable"]', createLocalToInstanceAssociation);
1349-
Event.on(workspace, 'editor:wb-removedChild', 'wb-contains, wb-context, wb-step, wb-expression', function(evt){
1350-
console.log('caught wb-removedChild: %o', evt);
1351-
});
13521342

13531343
Event.on(workspace, 'editor:click', 'wb-disclosure', toggleClosed);
13541344

js/widget.js

-25
Original file line numberDiff line numberDiff line change
@@ -164,30 +164,5 @@ Event.on(window, 'ui:dblclick', 'wb-splitter', function(evt){
164164
}
165165
});
166166

167-
// Observe child changes
168-
169-
var observer = new MutationObserver(function(mutations){
170-
mutations.forEach(function(mutation){
171-
// send childAdded or childRemove event to parent element
172-
// should I filter this to only elements (otherwise text nodes will be included)?
173-
var parent = mutation.target;
174-
[].slice.apply(mutation.removedNodes).forEach(function(node){
175-
parent.dispatchEvent(new CustomEvent('removeChild', {
176-
bubbles: true,
177-
detail: node
178-
}));
179-
});
180-
[].slice.apply(mutation.addedNodes).forEach(function(node){
181-
parent.dispatchEvent(new CustomEvent('addChild', {
182-
bubbles: true,
183-
detail: node
184-
}));
185-
});
186-
});
187-
});
188-
189-
var config = { childList: true, subtree: true };
190-
191-
// observer.observe(document.body, config);
192167

193168
})();

0 commit comments

Comments
 (0)