Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
function validateStyleObject(
style: Object,
logInvalid: boolean,
deleteInvalid: boolean
): void {
for (const property in style) {
const value = style[property]
if (isPlainObject(value)) {
if (isNestedSelector(property) || isMediaQuery(property)) {
validateStyleObject(value, logInvalid, deleteInvalid)
} else {
if (deleteInvalid) {
delete style[property]
}
if (logInvalid) {
console.error(
`${deleteInvalid
? '[Deleted] '
: ' '}Invalid nested property. Only use nested media queries, pseudo classes, child selectors or &-combinators.
Maybe you forgot to add a plugin that resolves "${property}".`,
{
property,
value,
}
)
(ruleset, value, property) => {
if (isPlainObject(value)) {
if (isNestedSelector(property)) {
renderer._renderStyleToCache(
className,
value,
pseudo + normalizeNestedProperty(property),
media,
support
)
} else if (isMediaQuery(property)) {
const combinedMediaQuery = generateCombinedMediaQuery(
media,
property.slice(6).trim()
)
renderer._renderStyleToCache(
className,
value,
_renderStyleToClassNames(
{ _className, ...style }: Object,
pseudo: string = '',
media: string = '',
support: string = ''
): string {
let classNames = _className ? ` ${_className}` : ''
for (const property in style) {
const value = style[property]
if (isPlainObject(value)) {
if (isNestedSelector(property)) {
classNames += renderer._renderStyleToClassNames(
value,
pseudo + normalizeNestedProperty(property),
media,
support
)
} else if (isMediaQuery(property)) {
const combinedMediaQuery = generateCombinedMediaQuery(
media,
property.slice(6).trim()
)
classNames += renderer._renderStyleToClassNames(
value,
pseudo,
combinedMediaQuery,
support