ericclemmons / ericclemmons/unique-selector

If tested element doesn't have a parent, script fails with error

Open
#59 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
JavaScript
Stars
272
Forks
55
PR merge metrics
No merged PRs in 30d

Description

### Error:
![image](https://user-images.githubusercontent.com/47595390/180777851-8df06c15-4c26-49d2-ba31-4d4dc2e1bf4e.png)

### Function where needs to be done parent null check
/**
* Tests uniqueNess of the element inside its parent
* @param { Object } element
* @param { String } Selectors
* @return { Boolean }
*/
function testUniqueness( element, selector )
{
const { parentNode } = element;
const elements = **parentNode**.querySelectorAll( selector );
return elements.length === 1 && elements[ 0 ] === element;
}

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.