Fix updating attributes on SVG elements. Fixes #934 and #1114

This commit is contained in:
Steve Sanderson 2018-07-23 14:42:38 -07:00
parent d3f74b9f43
commit d2f74249b1
3 changed files with 14 additions and 4 deletions

View File

@ -79,7 +79,7 @@ export class BrowserRenderer {
const frame = batch.referenceFramesEntry(referenceFrames, frameIndex);
const siblingIndex = editReader.siblingIndex(edit);
const element = getLogicalChild(parent, childIndexAtCurrentDepth + siblingIndex);
if (element instanceof HTMLElement) {
if (element instanceof Element) {
this.applyAttribute(batch, componentId, element, frame);
} else {
throw new Error(`Cannot set attribute on non-element child`);

View File

@ -306,6 +306,10 @@ namespace Microsoft.AspNetCore.Blazor.E2ETest.Tests
var svgCircleElement = appElement.FindElement(By.XPath("//*[local-name()='circle' and namespace-uri()='http://www.w3.org/2000/svg']"));
Assert.NotNull(svgCircleElement);
Assert.Equal("10", svgCircleElement.GetAttribute("r"));
appElement.FindElement(By.TagName("button")).Click();
WaitAssert.Equal("20", () => svgCircleElement.GetAttribute("r"));
}
[Fact]

View File

@ -1,3 +1,9 @@
<svg height="250" width="250">
<circle cx="125" cy="125" r="100" fill="red" stroke="black" stroke-width="3" />
</svg>
<svg height="250" width=250>
<circle cx="125" cy="125" r=@radius fill="red" stroke="black" stroke-width="3" />
</svg>
<button onclick=@(() => { radius *= 2; })>Click me</button>
@functions {
int radius = 10;
}

Before

Width:  |  Height:  |  Size: 123 B

After

Width:  |  Height:  |  Size: 229 B