Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tag names fixes #33

Merged
merged 1 commit into from
Feb 15, 2015
Merged

Tag names fixes #33

merged 1 commit into from
Feb 15, 2015

Conversation

zertosh
Copy link
Member

@zertosh zertosh commented Feb 13, 2015

See #29.

This is still tag-like, nothing I can do about this case:

i<table
return data

But the rest looks good:

yvrgw

@zertosh
Copy link
Member Author

zertosh commented Feb 13, 2015

The code from the screenshot: http://pastebin.com/MkpPkKdH

@dashed
Copy link

dashed commented Feb 14, 2015

Interesting. I didn't know you can have whitespace between < and the tag name: < div />

Probably also need to ignore ? and : that are in ternary operator:

result = sell < buy? foo() : bar();

@dashed
Copy link

dashed commented Feb 14, 2015

This borks: result = sell <buy? foo() : bar(); (no whitespace between < and buy)

@zertosh
Copy link
Member Author

zertosh commented Feb 14, 2015

Ok so after re-reading the spec, I came up with a better match and fixed another bug. Basically, tag names are open-bracket _ identifier _ space|self-closing-bracket|closing-bracket. Also, tag names can have dashes (shadow dom?). So now these work:

vcauq

http://pastebin.com/yS2L6YAN

@zertosh zertosh changed the title Ignore tags that end in [ ( ; Tag names fixes Feb 14, 2015
@dashed
Copy link

dashed commented Feb 14, 2015

Nice.

For false positive scopes, I think we're hitting the limits of regex.

I haven't looked in too much, but I'm wondering if there can be jsx-tag-attributes-illegal much like jsx-tag-invalid.

@zertosh
Copy link
Member Author

zertosh commented Feb 14, 2015

@dashed #35

@zertosh
Copy link
Member Author

zertosh commented Feb 14, 2015

Alright, did laundry all that good saturday stuff, all the while, thinking about this. I stopped fucking around and looked at the tests:

https://github.com/facebook/react/blob/5126cee/vendor/fbtransform/transforms/__tests__/react-test.js
https://github.com/facebook/esprima/blob/b339b4c/test/fbtest.js#L28

So, I removed : as a valid identifier char (I could've shown this was legit - oh well) and tweaked it so you can't end in - or ..

pafdx

http://pastebin.com/NiTHyh45

Now it'll only match jsx tags if the identifier is immediately followed by a space or (self-)closing bracket. This is to avoid the case where unspaced greater-than comparisons are confused with jsx tags. Also narrowed the allowed chars for identifiers to match the spec.
zertosh added a commit that referenced this pull request Feb 15, 2015
@zertosh zertosh merged commit 2533b7b into master Feb 15, 2015
@zertosh zertosh deleted the fix-almost-looking-tags branch February 15, 2015 04:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants