Khan / aphrodite

Framework-agnostic CSS-in-JS with support for server-side rendering, browser prefixing, and minimum CSS generation
5.35k stars 188 forks source link

Map Ordering does not produce a proper hash #359

Open trueshot opened 5 years ago

trueshot commented 5 years ago

The Documentation says:

const styles = StyleSheet.create({
    ordered: new Map([
        ["margin", 0],
        ["marginLeft", 15],
    ]),
});

In the StyleSheet.create function this line causes a problem.

var stringVal = JSON.stringify(val);

It returns an empty object `{}' instead of the something that is related to the map.

The problem is the hash that represents the style is always the same. So if you try to create a new stylesheet (using the map option), you end up only updating the only stylesheet.

const styles = StyleSheet.create({
    ordered: new Map([
        ["margin", 0],
        ["marginLeft", 15],
    ]),
});
const styles1 = StyleSheet.create({
    foo: new Map([
        ["padding", 0],
        ["paddingLeft", 15],
    ]),
});

Both styles.ordered and styles1.foo refer to the same style (the hash the string '{}' is always '3hmsj'.