|
400 | 400 | } |
401 | 401 | // apply styling always under native or if we generated style |
402 | 402 | // or the cached style is not in document(!) |
403 | | - if (nativeShadow || (!style || !style.parentNode)) { |
| 403 | + if (nativeShadow) { |
404 | 404 | // update existing style only under native |
405 | | - if (nativeShadow && element._customStyle) { |
| 405 | + if (element._customStyle) { |
406 | 406 | element._customStyle.textContent = cssText; |
407 | 407 | style = element._customStyle; |
408 | 408 | // otherwise, if we have css to apply, do so |
409 | 409 | } else if (cssText) { |
410 | 410 | // apply css after the scope style of the element to help with |
411 | 411 | // style precedence rules. |
412 | | - style = styleUtil.applyCss(cssText, selector, |
413 | | - nativeShadow ? element.root : null, element._scopeStyle); |
| 412 | + style = styleUtil.applyCss(cssText, selector, element.root, |
| 413 | + element._scopeStyle); |
414 | 414 | } |
| 415 | + } else { |
| 416 | + // shady and no cache hit |
| 417 | + if (!style) { |
| 418 | + // apply css after the scope style of the element to help with |
| 419 | + // style precedence rules. |
| 420 | + style = styleUtil.applyCss(cssText, selector, null, |
| 421 | + element._scopeStyle); |
| 422 | + // shady and cache hit but not in document |
| 423 | + } else if (!style.parentNode) { |
| 424 | + styleUtil.applyStyle(style, null, element._scopeStyle); |
| 425 | + } |
| 426 | + |
415 | 427 | } |
416 | 428 | // ensure this style is our custom style and increment its use count. |
417 | 429 | if (style) { |
|
424 | 436 | } |
425 | 437 | return style; |
426 | 438 | }, |
427 | | - |
| 439 | + |
428 | 440 | // customStyle properties are applied if they are truthy or 0. Otherwise, |
429 | 441 | // they are skipped; this allows properties previously set in customStyle |
430 | 442 | // to be easily reset to inherited values. |
|
0 commit comments