Skip to content

Commit

Permalink
remove workaround for removedChild not working earlier
Browse files Browse the repository at this point in the history
  • Loading branch information
dethe committed Oct 4, 2015
1 parent e04df83 commit 5143532
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 39 deletions.
6 changes: 2 additions & 4 deletions docs/custom_events.md
Expand Up @@ -14,9 +14,9 @@ Fired when a block is added to a script. When a block is moved, it is removed, t

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

## wb-remove
## wb-removedChild

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

## wb-delete

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

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


10 changes: 0 additions & 10 deletions js/block.js
Expand Up @@ -408,13 +408,6 @@ ExpressionProto.detachedCallback = function expressionDetached(){
sib.classList.remove('hide');
});
}
if (this.parent.localName !== 'wb-local'){
var blockParent = dom.closest(this.parent, 'wb-expression, wb-step, wb-context');
// FIXME: Is this needed or was it a workaround for wb-removedChild not firing?
if (blockParent){
Event.trigger(blockParent, 'wb-removedChild', this);
}
}
this.parent = null;
};

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

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

Expand Down
25 changes: 0 additions & 25 deletions js/widget.js
Expand Up @@ -164,30 +164,5 @@ Event.on(window, 'ui:dblclick', 'wb-splitter', function(evt){
}
});

// Observe child changes

var observer = new MutationObserver(function(mutations){
mutations.forEach(function(mutation){
// send childAdded or childRemove event to parent element
// should I filter this to only elements (otherwise text nodes will be included)?
var parent = mutation.target;
[].slice.apply(mutation.removedNodes).forEach(function(node){
parent.dispatchEvent(new CustomEvent('removeChild', {
bubbles: true,
detail: node
}));
});
[].slice.apply(mutation.addedNodes).forEach(function(node){
parent.dispatchEvent(new CustomEvent('addChild', {
bubbles: true,
detail: node
}));
});
});
});

var config = { childList: true, subtree: true };

// observer.observe(document.body, config);

})();

0 comments on commit 5143532

Please sign in to comment.