mirror of
https://github.com/atom/atom.git
synced 2026-01-23 22:08:08 -05:00
Text inside of tags is HTML escaped.
This commit is contained in:
@@ -30,6 +30,10 @@ describe "Builder", ->
|
||||
builder.tag 'div', 22
|
||||
expect(builder.toHtml()).toBe "<div>22</div>"
|
||||
|
||||
it "HTML escapes tag text", ->
|
||||
builder.tag('div', "<br/>")
|
||||
expect(builder.toHtml()).toBe "<div><br/></div>"
|
||||
|
||||
it "can generate tags with attributes", ->
|
||||
builder.tag 'div', id: 'foo', class: 'bar'
|
||||
fragment = builder.toFragment()
|
||||
|
||||
@@ -2,5 +2,11 @@ module.exports =
|
||||
class Text
|
||||
constructor: (@string) ->
|
||||
|
||||
toHtml: -> @string
|
||||
toHtml: ->
|
||||
@string
|
||||
.replace(/&/g, '&')
|
||||
.replace(/"/g, '"')
|
||||
.replace(/'/g, ''')
|
||||
.replace(/</g, '<')
|
||||
.replace(/>/g, '>')
|
||||
|
||||
|
||||
Reference in New Issue
Block a user