Skip to content

Commit

Permalink
Merge pull request #255 from julienc91/main
Browse files Browse the repository at this point in the history
fix: #254
  • Loading branch information
taoqf authored Oct 25, 2023
2 parents d4f2861 + 8e4e9e0 commit 331b908
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/nodes/html.ts
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,7 @@ export default class HTMLElement extends Node {
*/
public get rawText() {
// https://github.com/taoqf/node-html-parser/issues/249
if (/br/i.test(this.rawTagName)) {
if (/^br$/i.test(this.rawTagName)) {
return '\n';
}
return this.childNodes.reduce((pre, cur) => {
Expand Down
10 changes: 10 additions & 0 deletions test/tests/issues/254.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
const { parse } = require('@test/test-target');

describe('issue 254', function () {
it('abbr in innertext should not turn into \\n', function () {
const html = `<div>Hello <abbr>World</abbr></div>`;
const root = parse(html);
const div = root.querySelector('div');
div.innerText.should.eql(`Hello World`);
});
});

0 comments on commit 331b908

Please sign in to comment.