From 6578bd0c82b5cbb0cd6f6fea0787fb7ce820d4e7 Mon Sep 17 00:00:00 2001 From: Brian Ford Date: Wed, 30 Oct 2013 14:51:52 -0700 Subject: chore: move getBlockElements to Angular.js --- src/Angular.js | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) (limited to 'src/Angular.js') diff --git a/src/Angular.js b/src/Angular.js index 0cdeab3f..df236e05 100644 --- a/src/Angular.js +++ b/src/Angular.js @@ -79,7 +79,8 @@ -assertArg, -assertArgFn, -assertNotHasOwnProperty, - -getter + -getter, + -getBlockElements */ @@ -1318,3 +1319,25 @@ function getter(obj, path, bindFnToScope) { } return obj; } + +/** + * Return the siblings between `startNode` and `endNode`, inclusive + * @param {Object} object with `startNode` and `endNode` properties + * @returns jQlite object containing the elements + */ +function getBlockElements(block) { + if (block.startNode === block.endNode) { + return jqLite(block.startNode); + } + + var element = block.startNode; + var elements = [element]; + + do { + element = element.nextSibling; + if (!element) break; + elements.push(element); + } while (element !== block.endNode); + + return jqLite(elements); +} -- cgit v1.2.3