Skip to content

Instantly share code, notes, and snippets.

@kaid
Created April 23, 2015 09:36
Show Gist options
  • Save kaid/dfb2c42b8a74c561bb22 to your computer and use it in GitHub Desktop.
Save kaid/dfb2c42b8a74c561bb22 to your computer and use it in GitHub Desktop.
get current surrounding block in context
get currentBlock() {
let anchor = this.selected.anchor
, context = this.context;
if (!anchor) return;
return (function traverseUp(node) {
let block = node
, parent = node.parentNode;
if (parent && parent !== context) {
block = traverseUp(parent);
}
return block;
})(anchor);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment