You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Are you reporting to the correct repository? (there are multiple AngleSharp libraries, e.g., AngleSharp.Css for CSS support)
Did you perform a search in the issues?
For more information, see the CONTRIBUTING guide.
Description
I have a self-closing element and now want to add a child element.
Steps to Reproduce
Here's a complete repo:
[TestMethod]publicvoidTestInsertChildToSelfClosingElementSimple(){varxml=""" <ac:structured-macro ac:name="children"/> """;varconfig=Configuration.Default.With(HtmlEntityProvider.Resolver).WithDefaultLoader(newLoaderOptions{IsResourceLoadingEnabled=true}).WithCss().WithXml();varcontext=BrowsingContext.New(config);varparser=newXmlParser(newXmlParserOptions(),context);vardoc=parser.ParseDocument(xml);varparentElement=doc.DocumentElement;Assert.IsNotNull(parentElement);Assert.AreEqual(NodeFlags.SelfClosing,parentElement.Flags);varchild=doc.CreateElement("ac:parameter");child.SetAttribute("ac:name","dummy");parentElement.AppendChild(child);varparentElementXml=parentElement.ToXml();// it seems to be impossible to insert something into a self-closing element!? this test is here to document this factAssert.AreEqual("""<ac:structured-macro ac:name="children" /><ac:parameter ac:name="dummy"></ac:parameter>""",parentElementXml);}
Expected behavior: I expect the ac:parameter element to become a child element of the parent element. The outcome should look like this: <ac:structured-macro ac:name="children"><ac:parameter ac:name="dummy"></ac:parameter></ac:structured-macro>.
Actual behavior: The ac:parameter element is inserted as sibling instead: <ac:structured-macro ac:name="children" /><ac:parameter ac:name="dummy"></ac:parameter>.
Environment details: .NET 8, Windows 11 && Debian
Possible Solution
Cloning
I'd be fine with cloning the element if I could specify if the clone should be self-closing, or not. Basically optionally introduce the behavior that was once fixed here: #17 :D
I tried finding some specs that describe if it is valid to "transform" a self-closing element back to having children, but couldn't find anything. Cloning might introduce a compliant workaround if any specs prohibit changing the self-closing flag.
Changing the Flag
Maybe it is as easy as allowing to change the Flags property. Not sure about the consequences, though.
The text was updated successfully, but these errors were encountered:
Uh oh!
There was an error while loading. Please reload this page.
Bug Report
Prerequisites
AngleSharp.Css
for CSS support)For more information, see the
CONTRIBUTING
guide.Description
I have a self-closing element and now want to add a child element.
Steps to Reproduce
Here's a complete repo:
Expected behavior: I expect the
ac:parameter
element to become a child element of the parent element. The outcome should look like this:<ac:structured-macro ac:name="children"><ac:parameter ac:name="dummy"></ac:parameter></ac:structured-macro>
.Actual behavior: The
ac:parameter
element is inserted as sibling instead:<ac:structured-macro ac:name="children" /><ac:parameter ac:name="dummy"></ac:parameter>
.Environment details: .NET 8, Windows 11 && Debian
Possible Solution
Cloning
I'd be fine with cloning the element if I could specify if the clone should be self-closing, or not. Basically optionally introduce the behavior that was once fixed here: #17 :D
I tried finding some specs that describe if it is valid to "transform" a self-closing element back to having children, but couldn't find anything. Cloning might introduce a compliant workaround if any specs prohibit changing the self-closing flag.
Changing the Flag
Maybe it is as easy as allowing to change the Flags property. Not sure about the consequences, though.
The text was updated successfully, but these errors were encountered: