New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Feature Request] $.fn.contents() supports <template /> #3436
Comments
I know this "return something different depending on the collection" approach is a trademark of jQuery's early design, but I'm not a fan of continuing that tradition. Especially in this case where you can get the information via |
@dmethvin's comment is very sensible and hard to argue with, but I kinda want to argue with it anyway. This might be worth it. I'd like to see examples of return values. |
@timmywil one example - with HTML: <template>
<div id="template-div0">
<div id="template-div00"></div>
</div>
<div id="template-div1"></div>
<div id="template-div2"></div>
</template> if templateNode.content.childNodes produces a
|
Put together http://jsbin.com/mahudek/edit?html,js,output. templateNode.childNodes
// => NodeList[0]
templateNode.content.childNodes
// => NodeList[7], with text elements
templateNode.content.children
// => HTMLCollection[3] |
We discussed this one and given that the solution is short and we currently return an empty list, we can fix this. Something like, ...
jQuery.nodeName( elem, "template" ) && elem.content ?
elem.content.childNodes
... |
@TechQuery would you like to do the PR? |
Note that we have to be careful to not make the contents stop being inert once running |
@timmywil I'd like to make a new PR for this issue~ But one question: Which branch should I commit to ? |
@TechQuery master. We don't maintain versions 1.x & 2.x anymore. |
【重构】$.makeArray() 充分利用 JS 运行时引擎代码(基于 @ecalf 的研究) 【重构】$.fn.contents() 支持 template 元素(合并特性 jquery/jquery#3436) 【重构】$.dataHash() 核心基于 Crypto 标准 polyfill 重写 【优化】多处实现细节
TODO
$.fn.contents()
can return the reference ofHTMLTemplateElement.prototype.content
, notchildNodes
.Such as how
<iframe />
is supported --- https://github.com/jquery/jquery/blob/1.12-stable/src/traversing.js#L144Reference
https://developer.mozilla.org/en-US/docs/Web/HTML/Element/template#Attributes
The text was updated successfully, but these errors were encountered: