Ignore:
Timestamp:
11/25/21 22:08:24 (3 years ago)
Author:
Ema <ema_spirova@…>
Branches:
master
Children:
8d391a1
Parents:
59329aa
Message:

primeNG components

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trip-planner-front/node_modules/critters/src/dom.js

    r59329aa re29cc2e  
    1616
    1717import parse5 from 'parse5';
    18 import select from 'css-select';
     18import { selectAll, selectOne } from 'css-select';
     19import treeAdapter from 'parse5-htmlparser2-tree-adapter';
    1920
    2021// htmlparser2 has a relatively DOM-like tree format, which we'll massage into a DOM elsewhere
    21 const treeAdapter = require('parse5-htmlparser2-tree-adapter');
    22 
    2322const PARSE5_OPTS = {
    2423  treeAdapter
     
    3130 */
    3231export function createDocument(html) {
    33   const document = parse5.parse(html, PARSE5_OPTS);
     32  const document = /** @type {HTMLDocument} */ (
     33    parse5.parse(html, PARSE5_OPTS)
     34  );
    3435
    3536  defineProperties(document, DocumentExtensions);
     
    4849/**
    4950 * Serialize a Document to an HTML String
    50  * @param {Document} document   A Document, such as one created via `createDocument()`
     51 * @param {HTMLDocument} document   A Document, such as one created via `createDocument()`
    5152 */
    5253export function serializeDocument(document) {
     
    5455}
    5556
     57/** @typedef {treeAdapter.Document & typeof ElementExtensions} HTMLDocument */
     58
    5659/**
    5760 * Methods and descriptors to mix into Element.prototype
     61 * @private
    5862 */
    5963const ElementExtensions = {
    60   /** @extends htmlparser2.Element.prototype */
     64  /** @extends treeAdapter.Element.prototype */
    6165
    6266  nodeName: {
     
    131135 */
    132136const DocumentExtensions = {
    133   /** @extends htmlparser2.Document.prototype */
     137  /** @extends treeAdapter.Document.prototype */
    134138
    135139  // document is just an Element in htmlparser2, giving it a nodeType of ELEMENT_NODE.
     
    196200
    197201  querySelector(sel) {
    198     return select.selectOne(sel, this.documentElement);
     202    return selectOne(sel, this.documentElement);
    199203  },
    200204
     
    203207      return this;
    204208    }
    205     return select(sel, this.documentElement);
     209    return selectAll(sel, this.documentElement);
    206210  }
    207211};
Note: See TracChangeset for help on using the changeset viewer.