Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions lib/parsers.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ module.exports =
xmlparser:
name: "xml"
trigger: /<\/$/
test: /^</
test: /^<.*?>/
parse: (text) ->
result = {
opening: false
Expand All @@ -39,9 +39,8 @@ module.exports =
type: @name
length: 0
}
match = text.match(/^<(\/)?([^\s\/<>!][^\s\/<>]*)(\s+([\w-:\[\]\(\)\*\@\#]+|\{\.\.\..*?\})(=["'`{]([\S\s]*?)["'`}])?)*\s*(\/)?>/i)

match = text.match(/^<(\/)?([^\s\/<>!][^\s\/<>]*)(\s+([\w-:\[\]\(\)\*\@\#]+)(=["'`{]([\S\s]*?)["'`}])?)*\s*(\/)?>/i)
# match = text.match(/^<(\/)?([^\s\/<>!][^\s\/<>]*)(\s+([\w-:]+)(=["'`{]([\S\s]*?)["'`}])?)*\s*(\/)?>/i)
if match
result.element = match[2]
result.length = match[0].length
Expand Down
11 changes: 11 additions & 0 deletions spec/parsers-spec.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,17 @@ describe "xmlparser", ->
length: 53
}

it "works with JSX spread properties", ->
text = "<MyComponent {...props} {...{ style: { fontFamily: 'Comic Sans MS' } }}>"
expect(xmlparser.parse(text)).toEqual {
opening: true
closing: false
selfClosing: false
element: 'MyComponent'
type: 'xml'
length: 72
}

it "works around lone properties", ->
text = "<input type=\"text\" required/>"
expect(xmlparser.parse(text)).toEqual {
Expand Down