Skip to content

Latest commit

 

History

History
35 lines (24 loc) · 1.21 KB

quoted-hash-attribute-selectors.md

File metadata and controls

35 lines (24 loc) · 1.21 KB

Attribute selectors which include a "#" must be quoted

Selectors such as a[href=#main] are not valid CSS syntax because the value contains special characters that are not quoted. Until jQuery 1.11.3/2.1.4 this was accepted, but the behavior is non-standard and was never documented. In later versions this selector throws an error. In some cases with complex selectors, Migrate may not attempt a repair. In those cases a fatal error will be logged on the console and you will need to fix the selector manually.

Put quotes around any attribute values that have special characters, e.g. a[href="#main"]. The warning message contains the selector that caused the problem, use that to find the selector in the source files.

Rule Details

Examples of incorrect code for this rule:

$('[href=#main]')

var selector = '[href=#main']

Examples of correct code for this rule:

$('[href="#main"]')

var selector = '[href="#main"]'

Further Reading