1.2.0 • Published 8 years ago

closest-parent-by-attributes v1.2.0

Weekly downloads
4
License
MIT
Repository
github
Last release
8 years ago

Get closest parent which has specified attributes

This module implemented to get selector of clicked nodes for web analytics configuration automated check

Build Status Coverage Status

<ul class="menu">
    <li class="menu-item">
        <a class="menu-link" title="Click to go" data-interaction-id="12345"> <!-- This node has analytics attributes -->
            <span class="click-target">Click target</span> <!-- This is click target -->
        </a>
    </li>
</ul>
getClosestParentByAttributes(clickTarget, ['class', 'title', 'data-interaction-id']
// returns [class="menu-link"][title="Click to go"][data-interaction-id="12345"] span