Created
April 23, 2015 09:36
-
-
Save kaid/dfb2c42b8a74c561bb22 to your computer and use it in GitHub Desktop.
get current surrounding block in context
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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