p_css 0.1.6 → 0.1.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: c46687ed2138f367e3d83b51065e7faaeea99190ba035f47f0a9ad9ae7fabcbb
4
- data.tar.gz: 773fb3861bb5f5c18bf5027327592477349747d7dde550d93b640add292c5b4b
3
+ metadata.gz: b70a7f4978f6311a69ce05d16a2c1aa00c4aa5b2f4f68cb885d259c84ad76a63
4
+ data.tar.gz: 58d2dd272ab27d073338261d33d5a3d7012ae9ff1e61c0f724a56a0d78bd078d
5
5
  SHA512:
6
- metadata.gz: 161f1b01423d7389446bbc32bc2df68812f35423c2e8c4ab8b94493a02e2b7e1b032c2b94c6c60c1e0b11411117326ad68dda66d2ebe1c88a6ab0a13fe1aa30a
7
- data.tar.gz: 71e99867725196832e2598d4b3e0ffb8e40f5aef62b36ce95fd2785a3eacf114113253206db2731764450d8e6fde5f3940bbef01b74286429e58da26d0fa6e73
6
+ metadata.gz: fcdd53e4472aa6f840efefdb6f930d8c3c7b5dee0b6b72f4e50c96f531028b01ce66e537bffee68aa885401c507657f773a8785a797b61a561c266b54e0e83fa
7
+ data.tar.gz: 867129f911254dbc806c92d895428cc54d08d20df2d68664d57a99e52026d17c51d4b726c9b5f4f0493fc10301dc42a2d79e2be53dc5da5298f4d9934a2fe492
data/README.md CHANGED
@@ -61,7 +61,7 @@ Or:
61
61
  bundle add p_css
62
62
  ```
63
63
 
64
- Ruby 3.4+ is required. The matcher works against any object that quacks like
64
+ Ruby 3.3+ is required. The matcher works against any object that quacks like
65
65
  a DOM element (`Nokogiri::XML::Element` works out of the box); Nokogiri is not
66
66
  a hard dependency.
67
67
 
@@ -350,7 +350,7 @@ These are deliberate omissions; pull requests welcome:
350
350
 
351
351
  ## Compatibility
352
352
 
353
- Ruby 3.4+. Tested on the current MRI. No mandatory runtime dependencies.
353
+ Ruby 3.3+. Tested on the current MRI. No mandatory runtime dependencies.
354
354
 
355
355
  ## License
356
356
 
data/lib/css/parser.rb CHANGED
@@ -207,8 +207,11 @@ module CSS
207
207
  AtRule.new(name:, prelude:, block:)
208
208
  end
209
209
 
210
+ # On EOF or a stop token (`}` while nested), the rule is dropped per
211
+ # §5.4.3 — but already-consumed prelude tokens are NOT put back. Rewinding
212
+ # would leave the caller's cursor at the same starting token and loop
213
+ # forever on input like `style="hidden"` (no `:` and no `{`).
210
214
  def consume_qualified_rule(nested:)
211
- saved = @pos
212
215
  prelude = []
213
216
 
214
217
  loop do
@@ -216,13 +219,9 @@ module CSS
216
219
 
217
220
  case t.type
218
221
  when :eof
219
- @pos = saved
220
222
  return nil
221
223
  when :rbrace
222
- if nested
223
- @pos = saved
224
- return nil
225
- end
224
+ return nil if nested
226
225
 
227
226
  prelude << consume
228
227
  when :semicolon
@@ -453,9 +453,15 @@ module CSS
453
453
 
454
454
  # Element protocol helpers ---------------------------------------
455
455
 
456
+ # Callers (LINK_TAGS.include?, case statements) compare against
457
+ # lowercase literals, so the result must be lowercase. But Nokogiri's
458
+ # HTML parsers already emit lowercase names — the .downcase only fires
459
+ # in XML / uppercase-tag cases. Skip the allocation when there's
460
+ # nothing to lower.
456
461
  def tag(element)
457
462
  name = element.respond_to?(:tag_name) ? element.tag_name : element.name
458
- name.to_s.downcase
463
+ name = name.to_s
464
+ name.match?(/[A-Z]/) ? name.downcase : name
459
465
  end
460
466
 
461
467
  def attr(element, name)
data/lib/css/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module CSS
2
- VERSION = '0.1.6'
2
+ VERSION = '0.1.8'
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: p_css
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.6
4
+ version: 0.1.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - Keita Urashima