Skip to content

Latest commit

 

History

History
76 lines (46 loc) · 2.21 KB

insignificant-branches.md

File metadata and controls

76 lines (46 loc) · 2.21 KB
layout tags
doc-api.html
argument-options

ally.get.insignificantBranches

Identifies all the branches of the DOM that do not contain any of the target elements

Description

The insignificant branches contain all highest level nodes (looking from the root context) that do not contain any target elements (specified in filter). For the following HTML, the insignificant branches of #target are [#sibling, #uncle-1, #uncle-2]. The insignificant branches of [#target, #target-2] are [#sibling, #uncle-1, #cousin-2]:

<div id="uncle-1">
  <div id="cousin-1"></div>
</div>
<div id="parent">
  <div id="target"></div>
  <div id="sibling"></div>
</div>
<div id="uncle-2">
  <div id="cousin-2"></div>
  <div id="target-2"></div>
</div>

Usage

var elements = ally.get.insignificantBranches({
  filter: '#target',
});

Arguments

Name Type Default Description
context <selector> documentElement The scope of the DOM in which to search. The first element of a collection is used.
filter <selector> required The significant elements to exclude from the search.

Returns

Array of HTMLElement.

Throws

TypeError if filter option is not specified.

Examples

Changes

  • Since v1.1.0 the context option can point to another document (e.g. <body> in an iframe)

Notes

Related resources

Contributing