@@ -15,7 +15,7 @@ import {name as isIdentifierName} from 'estree-util-is-identifier-name'
15
15
import { whitespace } from 'hast-util-whitespace'
16
16
import { find , hastToReact , html , svg } from 'property-information'
17
17
import { stringify as spaces } from 'space-separated-tokens'
18
- import styleToObject from 'style-to-object '
18
+ import styleToJs from 'style-to-js '
19
19
import { pointStart } from 'unist-util-position'
20
20
import { VFileMessage } from 'vfile-message'
21
21
@@ -26,7 +26,6 @@ const own = {}.hasOwnProperty
26
26
const emptyMap = new Map ( )
27
27
28
28
const cap = / [ A - Z ] / g
29
- const dashSomething = / - ( [ a - z ] ) / g
30
29
31
30
// `react-dom` triggers a warning for *any* white space in tables.
32
31
// To follow GFM, `mdast-util-to-hast` injects line endings between elements.
@@ -635,11 +634,8 @@ function createProperty(state, prop, value) {
635
634
* Throws `VFileMessage` when CSS cannot be parsed.
636
635
*/
637
636
function parseStyle ( state , value ) {
638
- /** @type {Style } */
639
- const result = { }
640
-
641
637
try {
642
- styleToObject ( value , replacer )
638
+ return styleToJs ( value , { reactCompat : true } )
643
639
} catch ( error ) {
644
640
if ( ! state . ignoreInvalidStyle ) {
645
641
const cause = /** @type {Error } */ ( error )
@@ -655,30 +651,6 @@ function parseStyle(state, value) {
655
651
throw message
656
652
}
657
653
}
658
-
659
- return result
660
-
661
- /**
662
- * Add a CSS property (normal, so with dashes) to `result` as a DOM CSS
663
- * property.
664
- *
665
- * @param {string } name
666
- * Key.
667
- * @param {string } value
668
- * Value
669
- * @returns {undefined }
670
- * Nothing.
671
- */
672
- function replacer ( name , value ) {
673
- let key = name
674
-
675
- if ( key . slice ( 0 , 2 ) !== '--' ) {
676
- if ( key . slice ( 0 , 4 ) === '-ms-' ) key = 'ms-' + key . slice ( 4 )
677
- key = key . replace ( dashSomething , toCamel )
678
- }
679
-
680
- result [ key ] = value
681
- }
682
654
}
683
655
684
656
/**
@@ -800,20 +772,6 @@ function transformStyleToCssCasing(from) {
800
772
return to
801
773
}
802
774
803
- /**
804
- * Make `$1` capitalized.
805
- *
806
- * @param {string } _
807
- * Whatever.
808
- * @param {string } $1
809
- * Single ASCII alphabetical.
810
- * @returns {string }
811
- * Capitalized `$1`.
812
- */
813
- function toCamel ( _ , $1 ) {
814
- return $1 . toUpperCase ( )
815
- }
816
-
817
775
/**
818
776
* Make `$0` dash cased.
819
777
*
0 commit comments