File tree Expand file tree Collapse file tree 2 files changed +20
-2
lines changed Expand file tree Collapse file tree 2 files changed +20
-2
lines changed Original file line number Diff line number Diff line change @@ -1022,7 +1022,9 @@ export function base_parse(data: string, options = {} as Partial<Options>) {
1022
1022
style : true ,
1023
1023
pre : true ,
1024
1024
} ;
1025
- const element_names = Object . keys ( elements ) ;
1025
+ const element_names = Object . keys ( elements ) . filter ( ( name ) => {
1026
+ return Boolean ( elements [ name ] ) ;
1027
+ } ) ;
1026
1028
const kBlockTextElements = element_names . map ( ( it ) => new RegExp ( `^${ it } $` , 'i' ) ) ;
1027
1029
const kIgnoreElements = element_names . filter ( ( it ) => elements [ it ] ) . map ( ( it ) => new RegExp ( `^${ it } $` , 'i' ) ) ;
1028
1030
Original file line number Diff line number Diff line change 1
1
const { parse } = require ( '@test/test-target' ) ;
2
2
3
- describe ( 'issue 242' , function ( ) {
3
+ describe . only ( 'issue 242' , function ( ) {
4
4
it ( `a.rawAttrs returns 'href="/" rel="home"' but a.getAttribute("href') returns undefined` , function ( ) {
5
5
const html = `<div><a href="/" rel="home">Git Hub</a></div>` ;
6
6
const root = parse ( html ) ;
@@ -10,4 +10,20 @@ describe('issue 242', function () {
10
10
a . rawAttrs . should . eql ( 'href="/" rel="home"' ) ;
11
11
a . getAttribute ( 'href' ) . should . eql ( '/' ) ;
12
12
} ) ;
13
+ it ( `get code` , function ( ) {
14
+ const html = `<pre>
15
+ <code>test</code>
16
+ </pre>` ;
17
+ const root = parse ( html , {
18
+ blockTextElements : {
19
+ script : true ,
20
+ noscript : true ,
21
+ style : true ,
22
+ pre : false
23
+ }
24
+ } ) ;
25
+ const list = root . getElementsByTagName ( "code" ) ;
26
+ const [ code ] = list ;
27
+ code . text . should . eql ( 'test' ) ;
28
+ } ) ;
13
29
} ) ;
You can’t perform that action at this time.
0 commit comments