-
Notifications
You must be signed in to change notification settings - Fork 100
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
issue #8 : case insensitive css attributes, import react's attribute map... #20
Conversation
…ribute mapping into attribute map
@@ -35,6 +35,19 @@ var ELEMENT_ATTRIBUTE_MAPPING = { | |||
} | |||
}; | |||
|
|||
var HTMLDOMPropertyConfig = require('react/lib/HTMLDOMPropertyConfig'); | |||
|
|||
//populate property map with ReactJS's attribute and property mappings |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please put a single space after the //
and capitalise the first word
Sorry it took me so long to see this, I don't think I got an email about it :( |
@Daniel15 |
I think this change should be fine, but it looks like there's currently some merge conflicts. I'd be happy to merge it if you resolve the conflicts :) |
Conflicts: package.json
@Daniel15 bump |
@@ -468,6 +481,12 @@ StyleParser.prototype = { | |||
var key = style.substr(0, firstColon); | |||
var value = style.substr(firstColon + 1).trim(); | |||
if (key !== '') { | |||
// Lowercase style name if not vendor specific | |||
// TODO better vendor prefix handling | |||
if(key[0] != '-') { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use triple equals for string equality, !==
.
Can you add a test for the browser prefix case?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Might be cleaner to use charAt
since you know it's a String.
@ssorallen |
@@ -497,6 +514,10 @@ StyleParser.prototype = { | |||
* @return {string} JSX style key | |||
*/ | |||
toJSXKey: function(key) { | |||
// Don't capitalize -ms- prefix | |||
if(key.startsWith('-ms-')) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
startsWith
is not yet standard and not widely supported.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Replaced with regex test now
@@ -136,6 +136,42 @@ describe('htmltojsx', function() { | |||
expect(converter.convert('<div style="font-size: 12pt">Test</div>').trim()) | |||
.toBe('<div style={{fontSize: \'12pt\'}}>Test</div>'); | |||
}); | |||
|
|||
it('should convert vendor-prefix "style" attributes', function() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fix the spacing here please - Looks like the it
lines use tabs but everything else uses spaces
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Alright, hopefully that fixes the last of it. Do you have some linting rules that could be put in here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks! I'll have to see if I can figure out which linting tools to use, as I don't have experience with setting up linters.
issue #8 : case insensitive css attributes, import react's attribute map...
...ping into attribute map
issue #8