Skip to content

Commit bbdadef

Browse files
authored
build: update to latest version of parse5 (#26086)
Bumps up the version of parse5 to the latest and resolves the various issues. Fixes #26076.
1 parent f21cf4a commit bbdadef

File tree

7 files changed

+26
-15
lines changed

7 files changed

+26
-15
lines changed

package.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,6 @@
155155
"@types/marked": "^2.0.0",
156156
"@types/node": "^16.10.9",
157157
"@types/node-fetch": "^2.5.5",
158-
"@types/parse5": "^6.0.3",
159158
"@types/selenium-webdriver": "^3.0.17",
160159
"@types/semver": "^7.3.9",
161160
"@types/send": "^0.17.1",
@@ -196,7 +195,7 @@
196195
"minimatch": "^3.0.4",
197196
"moment": "^2.29.1",
198197
"node-fetch": "^2.6.0",
199-
"parse5": "^6.0.1",
198+
"parse5": "^7.1.2",
200199
"postcss": "^8.4.17",
201200
"postcss-scss": "^4.0.4",
202201
"protractor": "^7.0.0",

src/cdk/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@
5353
"tslib": "0.0.0-TSLIB"
5454
},
5555
"optionalDependencies": {
56-
"parse5": "^5.0.0"
56+
"parse5": "^7.1.2"
5757
},
5858
"schematics": "./schematics/collection.json",
5959
"ng-update": {

src/cdk/schematics/BUILD.bazel

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@ ts_library(
3434
# TODO(devversion): Only include jasmine for test sources (See: tsconfig types).
3535
"@npm//@types/jasmine",
3636
"@npm//@types/glob",
37-
"@npm//@types/parse5",
3837
"@npm//@types/node",
3938
"@npm//glob",
4039
"@npm//parse5",

src/cdk/schematics/ng-update/html-parsing/elements.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@
66
* found in the LICENSE file at https://angular.io/license
77
*/
88

9-
import {ChildNode, Element, parseFragment} from 'parse5';
9+
import {parseFragment} from 'parse5';
10+
import {ChildNode, Element} from '../../utils';
1011

1112
/**
1213
* Parses a HTML fragment and traverses all AST nodes in order find elements that

src/cdk/schematics/utils/html-manipulation.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@
77
*/
88

99
import {SchematicsException, Tree} from '@angular-devkit/schematics';
10-
import {getChildElementIndentation} from './parse5-element';
11-
import {Element, parse as parseHtml} from 'parse5';
10+
import {Element, getChildElementIndentation} from './parse5-element';
11+
import {parse as parseHtml} from 'parse5';
1212

1313
/** Appends the given element HTML fragment to the `<head>` element of the specified HTML file. */
1414
export function appendHtmlElementToHead(host: Tree, htmlFilePath: string, elementHtml: string) {
@@ -32,7 +32,7 @@ export function appendHtmlElementToHead(host: Tree, htmlFilePath: string, elemen
3232

3333
// We always have access to the source code location here because the `getHeadTagElement`
3434
// function explicitly has the `sourceCodeLocationInfo` option enabled.
35-
const endTagOffset = headTag.sourceCodeLocation!.endTag.startOffset;
35+
const endTagOffset = headTag.sourceCodeLocation!.endTag!.startOffset;
3636
const indentationOffset = getChildElementIndentation(headTag);
3737
const insertion = `${' '.repeat(indentationOffset)}${elementHtml}`;
3838

@@ -81,7 +81,7 @@ export function addBodyClass(host: Tree, htmlFilePath: string, className: string
8181
} else {
8282
const recordedChange = host
8383
.beginUpdate(htmlFilePath)
84-
.insertRight(body.sourceCodeLocation!.startTag.endOffset - 1, ` class="${className}"`);
84+
.insertRight(body.sourceCodeLocation!.startTag!.endOffset - 1, ` class="${className}"`);
8585
host.commitUpdate(recordedChange);
8686
}
8787
}

src/cdk/schematics/utils/parse5-element.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,12 @@
77
*/
88

99
import {SchematicsException} from '@angular-devkit/schematics';
10-
import {Element} from 'parse5';
10+
import {DefaultTreeAdapterMap} from 'parse5';
11+
12+
// At the time of writing `parse5` doesn't expose the node interfaces directly, even though
13+
// they're used as return types, but We can still access them through `DefaultTreeAdapterMap`.
14+
export type Element = DefaultTreeAdapterMap['element'];
15+
export type ChildNode = DefaultTreeAdapterMap['childNode'];
1116

1217
/** Determines the indentation of child elements for the given Parse5 element. */
1318
export function getChildElementIndentation(element: Element) {

yarn.lock

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3682,11 +3682,6 @@
36823682
resolved "https://registry.yarnpkg.com/@types/parse-json/-/parse-json-4.0.0.tgz#2f8bb441434d163b35fb8ffdccd7138927ffb8c0"
36833683
integrity sha512-//oorEZjL6sbPcKUaCdIGlIUeH26mgzimjBB77G6XRgnDl/L5wOnpyBGRe/Mmf5CVW3PwEBE1NjiMZ/ssFh4wA==
36843684

3685-
"@types/parse5@^6.0.3":
3686-
version "6.0.3"
3687-
resolved "https://registry.yarnpkg.com/@types/parse5/-/parse5-6.0.3.tgz#705bb349e789efa06f43f128cef51240753424cb"
3688-
integrity sha512-SuT16Q1K51EAVPz1K29DJ/sXjhSQ0zjvsypYJ6tlwVsRV9jwW5Adq2ch8Dq8kDBCkYnELS7N7VNCSB5nC56t/g==
3689-
36903685
"@types/ps-tree@^1.1.2":
36913686
version "1.1.2"
36923687
resolved "https://registry.yarnpkg.com/@types/ps-tree/-/ps-tree-1.1.2.tgz#5c60773a38ffb1402e049902a7b7a8d3c67cd59a"
@@ -7118,6 +7113,11 @@ entities@^2.0.0:
71187113
resolved "https://registry.yarnpkg.com/entities/-/entities-2.2.0.tgz#098dc90ebb83d8dffa089d55256b351d34c4da55"
71197114
integrity sha512-p92if5Nz619I0w+akJrLZH0MX0Pb5DX39XOwQTtXSdQQOaYH03S1uIQp4mhOZtAXrxq4ViO67YTiLBo2638o9A==
71207115

7116+
entities@^4.4.0:
7117+
version "4.4.0"
7118+
resolved "https://registry.yarnpkg.com/entities/-/entities-4.4.0.tgz#97bdaba170339446495e653cfd2db78962900174"
7119+
integrity sha512-oYp7156SP8LkeGD0GF85ad1X9Ai79WtRsZ2gxJqtBuzH+98YUV6jkHEKlZkMbcrjJjIVJNIDP/3WL9wQkoPbWA==
7120+
71217121
env-paths@^2.2.0:
71227122
version "2.2.1"
71237123
resolved "https://registry.yarnpkg.com/env-paths/-/env-paths-2.2.1.tgz#420399d416ce1fbe9bc0a07c62fa68d67fd0f8f2"
@@ -12100,6 +12100,13 @@ parse5@^6.0.1:
1210012100
resolved "https://registry.yarnpkg.com/parse5/-/parse5-6.0.1.tgz#e1a1c085c569b3dc08321184f19a39cc27f7c30b"
1210112101
integrity sha512-Ofn/CTFzRGTTxwpNEs9PP93gXShHcTq255nzRYSKe8AkVpZY7e1fpmTfOyoIvjP5HG7Z2ZM7VS9PPhQGW2pOpw==
1210212102

12103+
parse5@^7.1.2:
12104+
version "7.1.2"
12105+
resolved "https://registry.yarnpkg.com/parse5/-/parse5-7.1.2.tgz#0736bebbfd77793823240a23b7fc5e010b7f8e32"
12106+
integrity sha512-Czj1WaSVpaoj0wbhMzLmWD69anp2WH7FXMB9n1Sy8/ZFF9jolSQVMu1Ij5WIyGmcBmhk7EOndpO4mIpihVqAXw==
12107+
dependencies:
12108+
entities "^4.4.0"
12109+
1210312110
1210412111
version "0.0.5"
1210512112
resolved "https://registry.yarnpkg.com/parseqs/-/parseqs-0.0.5.tgz#d5208a3738e46766e291ba2ea173684921a8b89d"

0 commit comments

Comments
 (0)