querySelector

Type:Function
Status:stable
Since:1.0.0
Platform:js
@blackbyte.sugar.js.dom.query

Enhanced proxy of the Element.querySelector function that let you specify if you want an element that is visible, or even that is in the viewport

Params

  1. selector*-String

    The css selector to search

  2. settings*-Object

    The settings of the query

Return

  1. -HTMLElement

    The founded element

Example

import { querySelector } from '@blackbyte/sugar/dom';
// simple query
const elm = querySelector('.a-cool-css-selector');

// get an element that is in the viewport
const elm = querySelector('.a-cool-css-selector', {
  inViewport : true
});

Settings

  1. visible-Boolean

    Specify if you want only the visible nodes

  2. inViewport-Boolean

    Specify if you want only the nodes that are in the viewport

  3. $rootNodedocument.bodyHTMLElement

    Specify the root node from where you want to query

Todo

  • testsnormal