Skip to content

Commit aaa15bd

Browse files
Fix the '::after' selector (#52105)
1 parent fa7f7ba commit aaa15bd

File tree

5 files changed

+25
-9
lines changed

5 files changed

+25
-9
lines changed

src/Components/Web.JS/dist/Release/blazor.server.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/Components/Web.JS/dist/Release/blazor.web.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/Components/Web.JS/dist/Release/blazor.webview.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/Components/Web.JS/src/Rendering/BrowserRenderer.ts

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
import { RenderBatch, ArrayBuilderSegment, RenderTreeEdit, RenderTreeFrame, EditType, FrameType, ArrayValues } from './RenderBatch/RenderBatch';
55
import { EventDelegator } from './Events/EventDelegator';
6-
import { LogicalElement, PermutationListEntry, toLogicalElement, insertLogicalChild, removeLogicalChild, getLogicalParent, getLogicalChild, createAndInsertLogicalContainer, isSvgElement, permuteLogicalChildren, getClosestDomElement, emptyLogicalElement } from './LogicalElements';
6+
import { LogicalElement, PermutationListEntry, toLogicalElement, insertLogicalChild, removeLogicalChild, getLogicalParent, getLogicalChild, createAndInsertLogicalContainer, isSvgElement, permuteLogicalChildren, getClosestDomElement, emptyLogicalElement, getLogicalChildrenArray } from './LogicalElements';
77
import { applyCaptureIdToElement } from './ElementReferenceCapture';
88
import { attachToEventDelegator as attachNavigationManagerToEventDelegator } from '../Services/NavigationManager';
99
import { applyAnyDeferredValue, tryApplySpecialProperty } from './DomSpecialPropertyUtil';
@@ -41,15 +41,18 @@ export class BrowserRenderer {
4141
throw new Error(`Root component '${componentId}' could not be attached because its target element is already associated with a root component`);
4242
}
4343

44+
// If we want to append content to the end of the element, we create a new logical child container
45+
// at the end of the element and treat that as the new parent.
46+
if (appendContent) {
47+
const indexAfterLastChild = getLogicalChildrenArray(element).length;
48+
element = createAndInsertLogicalContainer(element, indexAfterLastChild);
49+
}
50+
4451
markAsInteractiveRootComponentElement(element, true);
4552
this.attachComponentToElement(componentId, element);
4653
this.rootComponentIds.add(componentId);
4754

48-
// If we want to preserve existing HTML content of the root element, we don't apply the mechanism for
49-
// clearing existing children. Rendered content will then append rather than replace the existing HTML content.
50-
if (!appendContent) {
51-
elementsToClearOnRootComponentRender.add(element);
52-
}
55+
elementsToClearOnRootComponentRender.add(element);
5356
}
5457

5558
public updateComponent(batch: RenderBatch, componentId: number, edits: ArrayBuilderSegment<RenderTreeEdit>, referenceFrames: ArrayValues<RenderTreeFrame>): void {

src/Components/test/E2ETest/Tests/HeadModificationTest.cs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,4 +110,17 @@ public void CanFallBackToDefaultTitle()
110110
// Assert the title is now the default
111111
Browser.Equal("Basic test app", () => Browser.Title);
112112
}
113+
114+
[Fact]
115+
public void HeadContentGetsAppendedToEndOfHead()
116+
{
117+
Browser.MountTestComponent<HeadModification>();
118+
119+
// Assert that the <meta id="meta-description"> element is the last in the <head>
120+
Browser.True(() =>
121+
{
122+
var metaDescriptionElement = Browser.FindElement(By.Id("meta-description"));
123+
return (bool)((IJavaScriptExecutor)Browser).ExecuteScript("return document.head.lastChild === arguments[0];", metaDescriptionElement);
124+
});
125+
}
113126
}

0 commit comments

Comments
 (0)