mirror of
https://github.com/zhigang1992/react-native-web.git
synced 2026-04-23 20:10:41 +08:00
A small error from referencing the wrong value caused prefixed values to be dropped. The patch also updated inline-style-prefixer and turns all vendor prefixes on by default. This provides the option to drop all the caniuse and bowser data that inline-style-prefixer uses (probably by forking the project and removing those dependencies). Fix #51
47 lines
1.1 KiB
JavaScript
47 lines
1.1 KiB
JavaScript
/**
|
|
* Copyright (c) 2016-present, Nicolas Gallagher.
|
|
* Copyright (c) 2015-present, Facebook, Inc.
|
|
* All rights reserved.
|
|
*
|
|
* @flow
|
|
*/
|
|
|
|
import flattenStyle from './flattenStyle'
|
|
import prefixer from './prefixer'
|
|
|
|
export default class StyleSheetRegistry {
|
|
static registerStyle(style: Object, store): number {
|
|
if (process.env.NODE_ENV !== 'production') {
|
|
Object.freeze(style)
|
|
}
|
|
|
|
const normalizedStyle = flattenStyle(style)
|
|
Object.keys(normalizedStyle).forEach((prop) => {
|
|
// add each declaration to the store
|
|
store.set(prop, normalizedStyle[prop])
|
|
})
|
|
}
|
|
|
|
static getStyleAsNativeProps(style, store) {
|
|
let _className
|
|
let _style = {}
|
|
const classList = []
|
|
const normalizedStyle = flattenStyle(style)
|
|
|
|
for (const prop in normalizedStyle) {
|
|
let styleClass = store.get(prop, normalizedStyle[prop])
|
|
|
|
if (styleClass) {
|
|
classList.push(styleClass)
|
|
} else {
|
|
_style[prop] = normalizedStyle[prop]
|
|
}
|
|
}
|
|
|
|
_className = classList.join(' ')
|
|
_style = prefixer(_style)
|
|
|
|
return { className: _className, style: _style }
|
|
}
|
|
}
|