We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
2 parents d4f2861 + 8e4e9e0 commit 331b908Copy full SHA for 331b908
src/nodes/html.ts
@@ -249,7 +249,7 @@ export default class HTMLElement extends Node {
249
*/
250
public get rawText() {
251
// https://github.com/taoqf/node-html-parser/issues/249
252
- if (/br/i.test(this.rawTagName)) {
+ if (/^br$/i.test(this.rawTagName)) {
253
return '\n';
254
}
255
return this.childNodes.reduce((pre, cur) => {
test/tests/issues/254.js
@@ -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