moxml 0.5.119 → 0.5.120

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: 7a30730e871854c7b88fc3b6a3498b4f4d5504ac47caa2aabcc530f2bf0eec96
4
- data.tar.gz: 8d4f301d7d100cab15cc55b4f0e3db36bc5e50916775adfd34f64b816546d466
3
+ metadata.gz: '08beda03b741fa08eec72ad7be564ecc57eda0446fbb8005fbf9a633d8233593'
4
+ data.tar.gz: cf087e7eeb0673b9085fc4d0c5f4f937fb7fb46a96e1186e000889169c201eb5
5
5
  SHA512:
6
- metadata.gz: 4b61a839f7399e0b9e9236b1d921cfc161714b114d73da1b737a80c98795d8c88b96f8e85e71c3a71f58a090578b2ba6ffa4ec57cb9a6309cb53296bb000b277
7
- data.tar.gz: b42fa624031b28da813039d441024be7766f8322fc54f247075b0c205cb79ec57052ababc789ab90f1c3b91b04a0ced4de85760af3178c1675aedd390fdd8046
6
+ metadata.gz: 95510cdd0f6ff20bde573e9ee0a1c6945fccf326c1557cc7891af74d633704cc8df3dbb912ef73e88f08888750f9a81e9345682cb67f672276b72c0741578e3f
7
+ data.tar.gz: c55e6d2963c9730cccda04d8e3ee22a6f5a295ac9f880ec498536afc9e5a5e493d34eed3b5970f4b422b7397c7cf1077e56a5c284b258c6e4cd89513ac10d53b
@@ -2220,11 +2220,22 @@ module Moxml
2220
2220
  # absorbed-source nodes upstream.
2221
2221
  child_doc = NN_DOCUMENT.bind_call(child)
2222
2222
  parent_doc = NN_DOCUMENT.bind_call(parent)
2223
- if child_doc && parent_doc &&
2224
- !child_doc.equal?(parent_doc) && child.node_type == :element
2225
- absorb_source_document(to_binding(parent_doc), to_binding(child_doc))
2226
- return structural_adopt(parent, child) unless
2227
- source_absorbed_into?(parent, child)
2223
+ if child_doc && parent_doc && !child_doc.equal?(parent_doc)
2224
+ if child.node_type == :element
2225
+ absorb_source_document(to_binding(parent_doc), to_binding(child_doc))
2226
+ return structural_adopt(parent, child) unless
2227
+ source_absorbed_into?(parent, child)
2228
+ else
2229
+ # moxml#347: the C add_child's foreign-child
2230
+ # fallback dispatches parent.add_child through
2231
+ # RUBY — on Identity natives the contract modules
2232
+ # shadow the C method, so that dispatch re-enters
2233
+ # Moxml's add_child forever. Foreign content kinds
2234
+ # (text/comment/CDATA/PI) rebuild in the parent's
2235
+ # pool directly; they carry no cross-document
2236
+ # identity worth a move.
2237
+ return rebuild_foreign_child(parent, child)
2238
+ end
2228
2239
  end
2229
2240
 
2230
2241
  doc = NN_DOCUMENT.bind_call(parent)
data/lib/moxml/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Moxml
4
- VERSION = "0.5.119"
4
+ VERSION = "0.5.120"
5
5
  end
@@ -146,4 +146,46 @@ RSpec.describe "leptris cross-document adoption" do
146
146
  expect(doc.at("//r/e").text).to eq("t")
147
147
  end
148
148
  end
149
+
150
+ # moxml#347: the C add_child's foreign-child fallback dispatches
151
+ # parent.add_child through Ruby — on Identity natives the contract
152
+ # modules shadow the C method and the dispatch re-enters Moxml's
153
+ # add_child (SystemStackError). Foreign content kinds rebuild in
154
+ # the parent's pool; foreign elements absorb/move.
155
+ context "when adding foreign children (moxml#347)" do
156
+ let(:fragment_xml) do
157
+ "<__root__>hello<b attr=\"1\"/>world<!-- note --><?tgt data?><![CDATA[x < y]]></__root__>"
158
+ end
159
+
160
+ it "appends every node kind from a same-context fragment" do
161
+ doc = ctx.parse("<bibitem/>")
162
+ frag = ctx.parse(fragment_xml)
163
+ frag.root.children.each { |c| doc.root.add_child(c) }
164
+ expect(doc.root.to_xml).to include("<b attr=\"1\">")
165
+ expect(doc.root.text).to include("hello")
166
+ expect(doc.root.to_xml).to include("<!-- note -->")
167
+ expect(doc.root.to_xml).to include("<?tgt data?>")
168
+ expect(doc.root.to_xml).to include("<![CDATA[x < y]]>")
169
+ end
170
+
171
+ it "appends every node kind across contexts without recursing" do
172
+ doc = ctx.parse("<bibitem/>")
173
+ frag = Moxml.new(:leptris).parse(fragment_xml)
174
+ frag.root.children.each { |c| doc.root.add_child(c) }
175
+ expect(doc.root.to_xml).to include("<b attr=\"1\">")
176
+ expect(doc.root.to_xml).to include("<!-- note -->")
177
+ expect(doc.root.to_xml).to include("<?tgt data?>")
178
+ expect(doc.root.to_xml).to include("<![CDATA[x < y]]>")
179
+ end
180
+
181
+ it "moves foreign elements by reference (the absorb path stays first)" do
182
+ doc = ctx.parse("<r><a/></r>")
183
+ other = Moxml.new(:leptris).parse("<other><new/></other>")
184
+ child = other.root.children.first
185
+ doc.root.add_child(child)
186
+ expect(doc.root.children.last).to eq(child)
187
+ expect(child["probe"] = "1").to eq("1")
188
+ expect(doc.at("//r/new")["probe"]).to eq("1")
189
+ end
190
+ end
149
191
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: moxml
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.119
4
+ version: 0.5.120
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ribose Inc.