Skip to content

Commit 331b908

Browse files
authored
Merge pull request #255 from julienc91/main
fix: #254
2 parents d4f2861 + 8e4e9e0 commit 331b908

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

src/nodes/html.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -249,7 +249,7 @@ export default class HTMLElement extends Node {
249249
*/
250250
public get rawText() {
251251
// https://github.com/taoqf/node-html-parser/issues/249
252-
if (/br/i.test(this.rawTagName)) {
252+
if (/^br$/i.test(this.rawTagName)) {
253253
return '\n';
254254
}
255255
return this.childNodes.reduce((pre, cur) => {

test/tests/issues/254.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
const { parse } = require('@test/test-target');
2+
3+
describe('issue 254', function () {
4+
it('abbr in innertext should not turn into \\n', function () {
5+
const html = `<div>Hello <abbr>World</abbr></div>`;
6+
const root = parse(html);
7+
const div = root.querySelector('div');
8+
div.innerText.should.eql(`Hello World`);
9+
});
10+
});

0 commit comments

Comments
 (0)