Skip to content

Commit

Permalink
Merge pull request #263 from facelessuser/bugfix/attr
Browse files Browse the repository at this point in the history
More correct attribute flag syntax
  • Loading branch information
facelessuser authored Mar 7, 2023
2 parents a12ac1d + 06538c5 commit bc9104d
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 2 deletions.
4 changes: 4 additions & 0 deletions docs/src/markdown/about/changelog.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Changelog

## 2.4.1

- **FIX**: Attribute syntax for case insensitive flag optionally allows a space, it does not require one.

## 2.4

- **NEW**: Update to support changes related to `:lang()` in the official CSS spec. `:lang("")` should match unspecified
Expand Down
2 changes: 1 addition & 1 deletion soupsieve/__meta__.py
Original file line number Diff line number Diff line change
Expand Up @@ -193,5 +193,5 @@ def parse_version(ver: str) -> Version:
return Version(major, minor, micro, release, pre, post, dev)


__version_info__ = Version(2, 4, 0, "final")
__version_info__ = Version(2, 4, 1, "final")
__version__ = __version_info__._get_canonical()
2 changes: 1 addition & 1 deletion soupsieve/css_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@
'''.format(nl=NEWLINE, ident=IDENTIFIER)
# Attribute value comparison. `!=` is handled special as it is non-standard.
ATTR = r'''
(?:{ws}*(?P<cmp>[!~^|*$]?=){ws}*(?P<value>{value})(?:{ws}+(?P<case>[is]))?)?{ws}*\]
(?:{ws}*(?P<cmp>[!~^|*$]?=){ws}*(?P<value>{value})(?:{ws}*(?P<case>[is]))?)?{ws}*\]
'''.format(ws=WSC, value=VALUE)

# Selector patterns
Expand Down
17 changes: 17 additions & 0 deletions tests/test_level4/test_attribute.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,23 @@ def test_attribute_forced_case_insensitive(self):
flags=util.HTML
)

def test_attribute_case_insensitive_flag_spacing(self):
"""Test attribute value case insensitivity spacing."""

self.assert_selector(
self.MARKUP,
"[class*=WORDSi]",
[],
flags=util.HTML
)

self.assert_selector(
self.MARKUP,
"[class*='WORDS'i]",
["0", "3", "pre"],
flags=util.HTML
)

def test_attribute_forced_case_insensitive_xml(self):
"""Test that attribute value case insensitivity can be forced in XML."""

Expand Down

0 comments on commit bc9104d

Please sign in to comment.