Skip to content

Commit d244ea5

Browse files
committed
make attributeStyleMap optional
1 parent 73a6085 commit d244ea5

File tree

5 files changed

+24
-21
lines changed

5 files changed

+24
-21
lines changed

packages/jss/.size-snapshot.json

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,30 @@
11
{
22
"dist/jss.js": {
3-
"bundled": 59659,
4-
"minified": 22190,
5-
"gzipped": 6640
3+
"bundled": 59644,
4+
"minified": 22179,
5+
"gzipped": 6636
66
},
77
"dist/jss.min.js": {
8-
"bundled": 58493,
9-
"minified": 21272,
10-
"gzipped": 6198
8+
"bundled": 58478,
9+
"minified": 21261,
10+
"gzipped": 6190
1111
},
1212
"dist/jss.cjs.js": {
13-
"bundled": 55063,
14-
"minified": 24149,
15-
"gzipped": 6694
13+
"bundled": 55048,
14+
"minified": 24138,
15+
"gzipped": 6689
1616
},
1717
"dist/jss.esm.js": {
18-
"bundled": 54567,
19-
"minified": 23745,
20-
"gzipped": 6614,
18+
"bundled": 54552,
19+
"minified": 23734,
20+
"gzipped": 6607,
2121
"treeshaked": {
2222
"rollup": {
23-
"code": 19332,
23+
"code": 19321,
2424
"import_statements": 281
2525
},
2626
"webpack": {
27-
"code": 20747
27+
"code": 20736
2828
}
2929
}
3030
}

packages/jss/src/StyleSheet.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@ import type {
99
UpdateArguments,
1010
JssStyle,
1111
Classes,
12-
KeyframesMap
12+
KeyframesMap,
13+
JssStyles
1314
} from './types'
1415

1516
export default class StyleSheet {
@@ -29,7 +30,7 @@ export default class StyleSheet {
2930

3031
queue: ?Array<Rule>
3132

32-
constructor(styles: Object, options: StyleSheetOptions) {
33+
constructor(styles: JssStyles, options: StyleSheetOptions) {
3334
this.attached = false
3435
this.deployed = false
3536
this.classes = {}
@@ -124,7 +125,7 @@ export default class StyleSheet {
124125
* Create and add rules.
125126
* Will render also after Style Sheet was rendered the first time.
126127
*/
127-
addRules(styles: Object, options?: RuleOptions): Array<Rule> {
128+
addRules(styles: JssStyles, options?: RuleOptions): Array<Rule> {
128129
const added = []
129130
for (const name in styles) {
130131
const rule = this.addRule(name, styles[name], options)

packages/jss/src/renderers/DomRenderer.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ function getPropertyValue(
4141
): string {
4242
try {
4343
// Support CSSTOM.
44-
if ('attributeStyleMap' in cssRule) {
44+
if (cssRule.attributeStyleMap) {
4545
return cssRule.attributeStyleMap.get(prop)
4646
}
4747
return cssRule.style.getPropertyValue(prop)
@@ -72,7 +72,7 @@ function setProperty(
7272
}
7373

7474
// Support CSSTOM.
75-
if ('attributeStyleMap' in cssRule) {
75+
if (cssRule.attributeStyleMap) {
7676
cssRule.attributeStyleMap.set(prop, cssValue)
7777
} else {
7878
cssRule.style.setProperty(prop, cssValue)
@@ -93,7 +93,7 @@ function removeProperty(
9393
) {
9494
try {
9595
// Support CSSTOM.
96-
if ('attributeStyleMap' in cssRule) {
96+
if (cssRule.attributeStyleMap) {
9797
cssRule.attributeStyleMap.delete(prop)
9898
} else {
9999
cssRule.style.removeProperty(prop)

packages/jss/src/types/dom.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,5 @@ import {StylePropertyMap} from './cssom'
55
export type DOMString = string
66

77
export interface HTMLElementWithStyleMap extends HTMLElement {
8-
+attributeStyleMap: StylePropertyMap;
8+
+attributeStyleMap?: StylePropertyMap;
99
}

packages/jss/src/types/jss.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,8 @@ export type GenerateId = (rule: Rule, sheet?: StyleSheet) => string
6161
// Find a way to declare all types: Object|string|Array<Object>
6262
export type JssStyle = Object
6363

64+
export type JssStyles = {[string]: JssStyle}
65+
6466
export type JssValue =
6567
| string
6668
| number

0 commit comments

Comments
 (0)