Changeset e29cc2e for trip-planner-front/node_modules/critters/src/dom.js
- Timestamp:
- 11/25/21 22:08:24 (3 years ago)
- Branches:
- master
- Children:
- 8d391a1
- Parents:
- 59329aa
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trip-planner-front/node_modules/critters/src/dom.js
r59329aa re29cc2e 16 16 17 17 import parse5 from 'parse5'; 18 import select from 'css-select'; 18 import { selectAll, selectOne } from 'css-select'; 19 import treeAdapter from 'parse5-htmlparser2-tree-adapter'; 19 20 20 21 // 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 23 22 const PARSE5_OPTS = { 24 23 treeAdapter … … 31 30 */ 32 31 export function createDocument(html) { 33 const document = parse5.parse(html, PARSE5_OPTS); 32 const document = /** @type {HTMLDocument} */ ( 33 parse5.parse(html, PARSE5_OPTS) 34 ); 34 35 35 36 defineProperties(document, DocumentExtensions); … … 48 49 /** 49 50 * 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()` 51 52 */ 52 53 export function serializeDocument(document) { … … 54 55 } 55 56 57 /** @typedef {treeAdapter.Document & typeof ElementExtensions} HTMLDocument */ 58 56 59 /** 57 60 * Methods and descriptors to mix into Element.prototype 61 * @private 58 62 */ 59 63 const ElementExtensions = { 60 /** @extends htmlparser2.Element.prototype */64 /** @extends treeAdapter.Element.prototype */ 61 65 62 66 nodeName: { … … 131 135 */ 132 136 const DocumentExtensions = { 133 /** @extends htmlparser2.Document.prototype */137 /** @extends treeAdapter.Document.prototype */ 134 138 135 139 // document is just an Element in htmlparser2, giving it a nodeType of ELEMENT_NODE. … … 196 200 197 201 querySelector(sel) { 198 return select .selectOne(sel, this.documentElement);202 return selectOne(sel, this.documentElement); 199 203 }, 200 204 … … 203 207 return this; 204 208 } 205 return select (sel, this.documentElement);209 return selectAll(sel, this.documentElement); 206 210 } 207 211 };
Note:
See TracChangeset
for help on using the changeset viewer.