Index: Source/core/dom/shadow/ShadowRoot.cpp |
diff --git a/Source/core/dom/shadow/ShadowRoot.cpp b/Source/core/dom/shadow/ShadowRoot.cpp |
index 83df7d57a0ac95fe239537683a356d2a6f242638..a0153d9041a18ee0155e17d99eaba7c070eacc89 100644 |
--- a/Source/core/dom/shadow/ShadowRoot.cpp |
+++ b/Source/core/dom/shadow/ShadowRoot.cpp |
@@ -138,6 +138,13 @@ void ShadowRoot::recalcStyle(StyleChange change) |
{ |
// ShadowRoot doesn't support custom callbacks. |
ASSERT(!hasCustomStyleCallbacks()); |
+ if (!attached()) { |
+ attach(); |
+ // attach recalculates the style for all children. No need to do it twice. |
+ clearNeedsStyleRecalc(); |
+ clearChildNeedsStyleRecalc(); |
+ return; |
+ } |
StyleResolver* styleResolver = document()->styleResolver(); |
styleResolver->pushParentShadowRoot(this); |