How to use css-selector-generator - 3 common examples

To help you get started, we’ve selected a few css-selector-generator examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github b12io / kinase / src / components / Main / index.jsx View on Github external
import { connect } from 'react-redux';

import Highlighter from 'components/Highlighter';
import Sidebar from 'components/Sidebar';
import {
  selectElement as _selectElement,
  setExpanded as _setExpanded,
} from 'redux/proxyActions';
import {
  currentAnnotationSelector,
  currentFieldTypeSelector,
} from 'redux/selectors';

import styles from './style.scss';

const selectorGenerator = new CssSelectorGenerator({
  // TODO(jrbotros): Exclude specific classes (e.g., `tether-*`) but allow others
  selectors: ['id', 'tag', 'nthchild'],
});

class Main extends React.Component {
  state = {
    highlightTarget: null,
  };

  componentWillReceiveProps({ currentAnnotation }) {
    if (currentAnnotation !== this.props.currentAnnotation) {
      this.setState({ highlightTarget: null });
    }
  }

  getWrappedText(node) {
github solobat / wordcard / extension / pages / content / content.js View on Github external
function getPosition(selection) {
    const gen = new CssSelectorGenerator();
    const path = gen.getSelector(selection.baseNode.parentElement);
    const offset = [selection.baseOffset, selection.extentOffset];
    const pos = {
        url: window.location.href,
        path,
        offset
    };

    return pos;
}
github segmentio / daydream / src / content-scripts / index.js View on Github external
import Selector from 'css-selector-generator'

const selector = new Selector()

class EventRecorder {
  start () {
    const typeableElements = document.querySelectorAll('input, textarea')
    const clickableElements = document.querySelectorAll('a, button')

    for (let i = 0; i < typeableElements.length; i++) {
      typeableElements[i].addEventListener('keydown', this.handleKeydown)
    }

    for (let i = 0; i < clickableElements.length; i++) {
      clickableElements[i].addEventListener('click', this.handleClick)
    }
  }

  handleKeydown (e) {

css-selector-generator

JavaScript object that creates unique CSS selector for given element.

MIT
Latest version published 29 days ago

Package Health Score

80 / 100
Full package analysis

Popular css-selector-generator functions

Similar packages