Fred Tingaud 16f6c0aecf
Inline adoc when include has no additional value (#1940)
Inline adoc files when they are included exactly once.

Also fix language tags because this inlining gives us better information
on what language the code is written in.
2023-05-25 14:18:12 +02:00

64 lines
1.4 KiB
Plaintext

== Why is this an issue?
While ``++:<element_type>++`` and ``++[type="<element_type>"]++`` can both be used in jQuery to select elements by their type, ``++[type="<element_type>"]++`` is far faster because it can take advantage of the native DOM ``++querySelectorAll()++`` method in modern browsers.
This rule raises an issue when following selectors are used:
* ``++:checkbox++``
* ``++:file++``
* ``++:image++``
* ``++:password++``
* ``++:radio++``
* ``++:reset++``
* ``++:text++``
=== Noncompliant code example
[source,javascript]
----
var input = $( "form input:radio" ); // Noncompliant
----
=== Compliant solution
[source,javascript]
----
var input = $( "form input[type=radio]" ); // Compliant
----
ifdef::env-github,rspecator-view[]
'''
== Implementation Specification
(visible only on this page)
=== Message
Use the "[type='{0}']" selector here instead of ":{0}".
'''
== Comments And Links
(visible only on this page)
=== on 30 Apr 2015, 07:21:35 Ann Campbell wrote:
https://api.jquery.com/radio-selector/
=== on 30 Apr 2015, 07:57:05 Linda Martin wrote:
Reviewed!
=== on 6 May 2015, 08:29:55 Elena Vilchik wrote:
\[~ann.campbell.2] The same rule applies to 6 more selectors, so I updated rule accordingly. Could you verify it?
=== on 6 May 2015, 11:43:30 Ann Campbell wrote:
looks fine to me [~elena.vilchik]
=== on 1 Nov 2019, 17:30:35 Elena Vilchik wrote:
See \https://github.com/SonarSource/SonarJS/issues/1698
endif::env-github,rspecator-view[]