Skip to content

Commit e0fac2a

Browse files
committed
hidden/visible-selector: add note about performance
Fixes jquerygh-679 Closes jquerygh-682
1 parent 1d5f56a commit e0fac2a

File tree

3 files changed

+5
-0
lines changed

3 files changed

+5
-0
lines changed

entries/hidden-selector.xml

+1
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
<p>How <code>:hidden</code> is determined was changed in jQuery 1.3.2. An element is assumed to be hidden if it or any of its parents consumes no space in the document. CSS visibility isn't taken into account (therefore <code>$( elem ).css( "visibility", "hidden" ).is( ":hidden" ) == false</code>). The <a href="http://blog.jquery.com/2009/02/20/jquery-1-3-2-released/">release notes</a> outline the changes in more detail.</p>
2121
</longdesc>
2222
<note id="jquery-selector-extension" type="additional" data-selector=":hidden"/>
23+
<note id="hidden-forces-layout" type="additional"/>
2324
<example>
2425
<desc>Shows all hidden divs and counts hidden inputs.</desc>
2526
<code><![CDATA[

entries/visible-selector.xml

+1
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
<p>How <code>:visible</code> is calculated was changed in jQuery 1.3.2. The <a href="http://blog.jquery.com/2009/02/20/jquery-1-3-2-released/">release notes</a> outline the changes in more detail.</p>
1616
</longdesc>
1717
<note id="jquery-selector-extension" type="additional" data-selector=":visible"/>
18+
<note id="hidden-forces-layout" type="additional"/>
1819
<example>
1920
<desc>Make all visible divs turn yellow on click.</desc>
2021
<code><![CDATA[

notes.xsl

+3
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,9 @@
5858
<xsl:when test="@id = 'html-code-execution'">
5959
By design, any jQuery constructor or method that accepts an HTML string — <a href="/jQuery/">jQuery()</a>, <a href="/append/">.append()</a>, <a href="/after/">.after()</a>, etc. — can potentially execute code. This can occur by injection of script tags or use of HTML attributes that execute code (for example, <code>&lt;img onload=""&gt;</code>). Do not use these methods to insert strings obtained from untrusted sources such as URL query parameters, cookies, or form inputs. Doing so can introduce cross-site-scripting (XSS) vulnerabilities. Remove or escape any user input before adding content to the document.
6060
</xsl:when>
61+
<xsl:when test="@id = 'hidden-forces-layout'">
62+
Using this selector heavily can have performance implications, as it may force the browser to re-render the page before it can determine visibility. Tracking the visibility of elements via other methods, using a class for example, can provide better performance.
63+
</xsl:when>
6164
</xsl:choose>
6265
</xsl:template>
6366
</xsl:stylesheet>

0 commit comments

Comments
 (0)