tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

grid-highlighter.js (1301B)


      1 /* This Source Code Form is subject to the terms of the Mozilla Public
      2 * License, v. 2.0. If a copy of the MPL was not distributed with this
      3 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
      4 
      5 "use strict";
      6 
      7 /**
      8 * This module exports thunks.
      9 * Thunks are functions that can be dispatched to the Inspector Redux store.
     10 *
     11 * These functions receive one object with options that contains:
     12 * - dispatch() => function to dispatch Redux actions to the store
     13 * - getState() => function to get the current state of the entire Inspector Redux store
     14 * - inspector => object instance of Inspector client
     15 *
     16 * They provide a shortcut for React components to invoke the box model highlighter
     17 * without having to know where the highlighter exists.
     18 */
     19 
     20 module.exports = {
     21  /**
     22   * Show the grid highlighter for the given node front.
     23   *
     24   * @param {NodeFront} nodeFront
     25   *        Node that should be highlighted.
     26   * @param {object} options
     27   *        Optional configuration options passed to the grid highlighter
     28   */
     29  showGridHighlighter(nodeFront, options = {}) {
     30    return async thunkOptions => {
     31      const { inspector } = thunkOptions;
     32      if (!inspector) {
     33        return;
     34      }
     35 
     36      await inspector.highlighters.showGridHighlighter(nodeFront, options);
     37    };
     38  },
     39 };