JSF 在 SVG 之后吞下结束标签 [英] JSF swallows closing tag after SVG
问题描述
我在 <ul>
中使用了两个 <svg>
元素.
I'm using two <svg>
elements inside a <ul>
.
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:h="http://java.sun.com/jsf/html">
...
<ul>
<li>
<svg xmlns="http://www.w3.org/2000/svg" version="1.1" >...</svg>
</li>
<li>
<svg xmlns="http://www.w3.org/2000/svg" version="1.1" >...</svg>
</li>
</ul>
...
</html>
JSF 在呈现 HTML 时正在吞下第一个关闭的 </li>
.
JSF is swallowing the first closing </li>
when it's rendering the HTML.
这是一个错误还是我的 xhtml 无效?
Is this a bug or is my xhtml invalid?
我正在使用 Mojarra 2.1.7.
I'm using Mojarra 2.1.7.
更新:正如@BalusC 建议的那样,我将此报告给 莫哈拉人.
Update: As @BalusC suggested I reported this to the Mojarra Guys.
更新 2: 已使用 Mojarra 2.1.26 修复 和 2.2.3
Update 2: Fixed with Mojarra 2.1.26 and 2.2.3
推荐答案
我可以在 2.1.24 中重现它.我不确定这是否是 Facelets 的 SAX 解析器中的错误,但它确实看起来很像它在嵌套命名空间中混淆了.您使用 <svg xmlns>
声明一个新的默认 XML 命名空间,该命名空间似乎覆盖了 HTML 标记的 <html xmlns>
命名空间.我建议向 Mojarra 人报告这个问题.
I can reproduce it in 2.1.24. I'm not sure if this is a bug in Facelets' SAX parser but it indeed look much like that it got confused in nested namespaces. You're with <svg xmlns>
declaring a new default XML namespace which has seemingly overriden the <html xmlns>
one for HTML tags. I recommend to report this issue to Mojarra guys.
无论如何,在 Facelets 中使用 SVG 的正确方法是将整个 <svg>
内容拆分为自己的 .svg
文件并通过<ui:include>
.
In any case, the right way of using SVG in Facelets is to split off the whole <svg>
content into its own .svg
file and include it via <ui:include>
.
<ul>
<li>
<ui:include src="/resources/svg/one.svg" />
</li>
<li>
<ui:include src="/resources/svg/two.svg" />
</li>
</ul>
这样命名空间可以正常工作.额外的好处是,您的 SVG 可以通过这种方式立即重复使用.
This way the namespacing works fine. Additional benefit is, your SVGs are this way instantly reusable.
这篇关于JSF 在 SVG 之后吞下结束标签的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!