Skip to content

[BUG] tags inside of <title> are not parsed as text on Node.js #202

Closed
@remarkablemark

Description

@remarkablemark

Expected Behavior

Tags inside of <title> should be escaped as text on Node.js:

const parse = require('html-react-parser');
parse('<title><em>text</em></title>');

Output:

{
  '$$typeof': Symbol(react.element),
  type: 'title',
  key: null,
  ref: null,
  props: { children: '<em>text</em>' },
  _owner: null,
  _store: {}
}

Actual Behavior

Tags inside of <title> are parsed as React elements on Node.js:

const parse = require('html-react-parser');
parse('<title><em>text</em></title>');

Output:

{
  '$$typeof': Symbol(react.element),
  type: 'title',
  key: null,
  ref: null,
  props: {
    children: {
      '$$typeof': Symbol(react.element),
      type: 'em',
      key: null,
      ref: null,
      props: { children: 'text' },
      _owner: null,
      _store: {}
    }
  },
  _owner: null,
  _store: {}
}

Steps to Reproduce

See above.

Reproducible Demo

Repl.it: https://repl.it/@remarkablemark/html-react-parser-202

Environment

  • Version: 1.1.0
  • Platform: Node.js
  • Browser: N/A

Metadata

Metadata

Labels

bugSomething isn't working

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions