@@ -6,11 +6,33 @@ import { isFailure, isOmitted } from '../utils/value.js'
66import { serializeDeclarationBlock , serializeValue } from '../serialize.js'
77import expandShorthandDeclaration from '../parse/shorthand.js'
88import { getResolvedValue } from '../resolve.js'
9+ import { isOfType } from '../utils/dom/element.js'
10+ import { iterate } from '../utils/dom/collection.js'
911import logical from '../properties/logical.js'
1012import properties from '../properties/definitions.js'
1113import shorthands from '../properties/shorthands.js'
1214import { toLowerCase } from '../utils/string.js'
1315
16+ /**
17+ * @param {Element } element
18+ * @returns {boolean }
19+ */
20+ function hasResolvedStyle ( element ) {
21+ if ( ! element . isConnected ) {
22+ return false
23+ }
24+ const shadowRoot = element . parentElement ?. shadowRoot
25+ if ( shadowRoot ) {
26+ for ( const node of iterate ( shadowRoot . childNodes ) ) {
27+ if ( isOfType ( node , 'slot' ) && node . assignedNodes ( ) . some ( slotted => slotted === element ) ) {
28+ return true
29+ }
30+ }
31+ return false
32+ }
33+ return true
34+ }
35+
1436/**
1537 * @param {object } declaration
1638 * @param {object[] } declarations
@@ -173,7 +195,7 @@ export default class CSSStyleDeclarationImpl {
173195 return ''
174196 }
175197 if ( this . _computed ) {
176- if ( ! this . _ownerNode . isConnected || ( ! this . _ownerNode . slot && this . _ownerNode . parentElement ?. shadowRoot ) ) {
198+ if ( ! hasResolvedStyle ( this . _ownerNode ) ) {
177199 return ''
178200 }
179201 if ( shorthands . has ( name ) ) {
0 commit comments