5

I want to add HTML entities like   or & using a Dart class. I tried this :

my_element.nodes.add(new Text('&©'));

but as mentioned in Text class doc, markup is parsed into information, meaning everything is escaped, I guess. I read Node class doc looking for an Entity class; there is none, and I don't want to embed my entity in a tag:

my_element.nodes.add(new Element.html('<span>&amp;&copy;</span>'));

Which class should I use to add an HTML entity ?

Eric Lavoie
  • 5,121
  • 3
  • 32
  • 49

1 Answers1

7

DocumentFragment will do the job. This:

my_element.nodes.add(new DocumentFragment.html('&amp;&copy;'));

will output in your HTML document.

Darshan Rivka Whittle
  • 32,989
  • 7
  • 91
  • 109
Eric Lavoie
  • 5,121
  • 3
  • 32
  • 49