classlist 1.1.2 → 1.1.3

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: 6839a679e1d5e2f94e6f32750960f5f5cf495b750a2445a562086d9ee255e393
4
- data.tar.gz: c15228e2754ffc43a92ad71fd27aa6214e20cf8280b6df5edb605e0ea748ed54
3
+ metadata.gz: ec22dd9c1f5a694e833da806219a4e2fc738ad0649a8caa3acf96b75ba55a706
4
+ data.tar.gz: ede23289a61180d0866e5c4734d1853bc12b8ac21cfb1b3af477c9aff8d2cecf
5
5
  SHA512:
6
- metadata.gz: 531132536747ba27cd150418ae363470b577e8d7d1833d14b17a804841e7b90fa0f5402947e6c115599b957a60c3027a70e583714dba30bab8eeb5f256125d30
7
- data.tar.gz: c1e671df811f0e9e2dace56ad2dd2b91f2262ea24e3c0a1a05c1b855a6fa9d8bd0eda48213e5c09979edf3b5b7f2407bfe4603b236b56e196d0d153218805443
6
+ metadata.gz: 2de6755b0b6d59fc3b9534d16e97dfda5f858a6d06e46062ef729038e7bbf64d32612f134f2ee4990a5f098ec0877daddb2f0be0e64ef2296cc3af14d7753825
7
+ data.tar.gz: 7830b58c5677300c4f42bdd2a2dea0b03c11b75fd6958e773586bdbecf65d5c225d798268339eb181def6cc34eea74096e6e5e5d184dec56ea06cef81cf31010
data/CHANGELOG.md CHANGED
@@ -5,6 +5,16 @@ All notable changes to this project will be documented in this file.
5
5
  The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
6
6
  and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
7
 
8
+ ## 1.1.3 - 2026-10-06
9
+
10
+ ### Added
11
+
12
+ - Add support for Ruby 4.0 (no changes).
13
+
14
+ ### Fixed
15
+
16
+ - Adding a String or Array to a Classlist with pending operations no longer drops those operations.
17
+
8
18
  ## 1.1.2 - 2026-08-06
9
19
 
10
20
  ### Fixed
data/Rakefile CHANGED
@@ -10,4 +10,9 @@ Rake::TestTask.new(:test) do |t|
10
10
  t.test_files = FileList["test/**/test_*.rb"]
11
11
  end
12
12
 
13
+ desc "Run performance benchmarks, failing if any operation's runtime is scaling worse than expected"
14
+ task :benchmark do
15
+ FileList["test/benchmark/*_benchmark.rb"].sort.each { |f| load f }
16
+ end
17
+
13
18
  task default: %i[test standard]
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  class Classlist
4
- VERSION = "1.1.2"
4
+ VERSION = "1.1.3"
5
5
  end
data/lib/classlist.rb CHANGED
@@ -30,8 +30,13 @@ class Classlist
30
30
  result = other.merge(self)
31
31
  Classlist.new(result)
32
32
  else
33
- result = entries + build_entries(other)
34
- Classlist.new(result)
33
+ # Resolve pending operations on a copy, so they are not lost and this
34
+ # classlist (including any shared operations) is left unchanged.
35
+ result = Classlist.new
36
+ result.copy_from(self, {}.compare_by_identity)
37
+ result.resolve_operations
38
+ result.add(other)
39
+ result
35
40
  end
36
41
  end
37
42
 
@@ -151,6 +156,27 @@ class Classlist
151
156
  end
152
157
  end
153
158
 
159
+ protected
160
+
161
+ # Replaces entries and pending operations with copies of those in source, so
162
+ # resolving operations on this classlist doesn't change source.
163
+ #
164
+ # memo maps already copied operations to their copies by identity. An
165
+ # operation reachable through several paths is copied only once, so the copy
166
+ # resolves exactly like the original does.
167
+ def copy_from(source, memo)
168
+ @entries = source.entries.dup
169
+ @operations = source.operations.map { |operation| operation.deep_copy(memo) }
170
+ end
171
+
172
+ def deep_copy(memo)
173
+ memo.fetch(self) do
174
+ copy = memo[self] = dup
175
+ copy.copy_from(self, memo)
176
+ copy
177
+ end
178
+ end
179
+
154
180
  private
155
181
 
156
182
  attr_writer :entries
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: classlist
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.2
4
+ version: 1.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jakob Skjerning
@@ -55,7 +55,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
55
55
  - !ruby/object:Gem::Version
56
56
  version: '0'
57
57
  requirements: []
58
- rubygems_version: 4.0.6
58
+ rubygems_version: 4.0.16
59
59
  specification_version: 4
60
60
  summary: Ruby implementation of the Element.classList DOM API
61
61
  test_files: []