Safari 9更改DOM解析器?

时间:2015-10-01 11:01:33

标签: safari9

Safari 9让form标记在dom元素下消失。 Safari 8和Chrome和Firefox都很好。

enter image description here

  • 我的mac是优胜美地10.10.5。
  • Safari是9.0(10601.1.56.2)

我搜索了safari 9 documentation

https://developer.apple.com/library/prerelease/mac/releasenotes/General/WhatsNewInSafari/Articles/Safari_9.html

但我找不到解决方案。 有人有任何信息吗?

更新2015-10-05

这是template + form问题。

https://jsfiddle.net/svj7j2gs/

<form id="first-form">
  first-form
</form>
<template>
  <form id="second-form">
    second-form
  </form>
</template>
<form id="third-form">
  third-form
</form>

chrome result

#third-form表单标记已存在。

enter image description here

safari 9结果

删除了#third-form表单标记。

enter image description here

自Safari 7.1以来支持template标记? https://html.spec.whatwg.org/multipage/scripting.html#the-template-element

safari 8结果

enter image description here

多个帖子

如果它是一个错误,它超出了stackoverflow的范围。 所以我发布了Apple支持社区。 Safari 9 - broken DOM. Is it bug? | Apple Support Communities

1 个答案:

答案 0 :(得分:0)

这绝对是一个错误。

解决方案1 ​​:使用嵌套的form

将所需的template移到form上方

实施例

<form id="first-form">
    I'm fine here
</form>
<template>
    <form id="second-form">
        second-form
    </form>
</template>

解决方案2 :直接在模板后面和所需的form之前添加一个虚拟form。只有模板后面的第一个表单才会从DOM中删除。

实施例

<template>
    <form id="second-form">
        second-form
    </form>
</template>
<form id="third-form">
    I will get stripped
</form>
<form id="third-form">
    I will be fine here
</form>