(style, rule, sheet)
| 65 | } |
| 66 | |
| 67 | function onProcessStyle(style, rule, sheet) { |
| 68 | if (rule.type !== 'style') return style |
| 69 | |
| 70 | const styleRule = rule |
| 71 | |
| 72 | const container = styleRule.options.parent |
| 73 | let options |
| 74 | let replaceRef |
| 75 | for (const prop in style) { |
| 76 | const isNested = prop.indexOf('&') !== -1 |
| 77 | const isNestedConditional = prop[0] === '@' |
| 78 | |
| 79 | if (!isNested && !isNestedConditional) continue |
| 80 | |
| 81 | options = getOptions(styleRule, container, options) |
| 82 | |
| 83 | if (isNested) { |
| 84 | let selector = replaceParentRefs(prop, styleRule.selector) |
| 85 | // Lazily create the ref replacer function just once for |
| 86 | // all nested rules within the sheet. |
| 87 | if (!replaceRef) replaceRef = getReplaceRef(container, sheet) |
| 88 | // Replace all $refs. |
| 89 | selector = selector.replace(refRegExp, replaceRef) |
| 90 | |
| 91 | const name = `${styleRule.key}-${prop}` |
| 92 | if ('replaceRule' in container) { |
| 93 | // for backward compatibility |
| 94 | container.replaceRule(name, style[prop], {...options, selector}) |
| 95 | } else { |
| 96 | container.addRule(name, style[prop], {...options, selector}) |
| 97 | } |
| 98 | } else if (isNestedConditional) { |
| 99 | // Place conditional right after the parent rule to ensure right ordering. |
| 100 | container |
| 101 | .addRule(prop, {}, options) |
| 102 | .addRule(styleRule.key, style[prop], {selector: styleRule.selector}) |
| 103 | } |
| 104 | |
| 105 | delete style[prop] |
| 106 | } |
| 107 | |
| 108 | return style |
| 109 | } |
| 110 | |
| 111 | return {onProcessStyle} |
| 112 | } |
nothing calls this directly
no test coverage detected
searching dependent graphs…