moxml 0.5.129 → 0.5.130

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: 9f040a5d5fc3e041e15a54cc42aeb10ca5d3cc882ecc22ca97faa7d45cbbb2d5
4
- data.tar.gz: de59fd55dd4eff18451ddec5a20f246325be236313a55d0aeb4cab5af56ce4f9
3
+ metadata.gz: c2f099a606cb34b83d050cd7127593bc1403b3c2ae0d75f1d2d5afaad0107177
4
+ data.tar.gz: 1d1d777052f784a68363fc7efee322aeb53cfea53781927df1c0e424a165327e
5
5
  SHA512:
6
- metadata.gz: 668587c18c1bf04415c99e715460b1dece9f5619206d6a7fb1ffa8260a32be81f6faa20853eeca322b3b016523a589550711647362f03ff79f64ccc507ef8e03
7
- data.tar.gz: 7ff1f188edb97ee6f36c0294745232f1e1a4078bd6e94d567d56e649c01f5939617b345ebed2fe5b21bf325b6be1863f68b5af1acfb7171bd63b0a4bef58bd2a
6
+ metadata.gz: 28d300923fb7a5225aae5241ccbf3af90269ce73258ce1351260fb437df8a70f390a889fcccc98556202fcbcda15a0dbc2b1a9a8ab753e54f81d79a4132ab431
7
+ data.tar.gz: f8085292e7b0bad93fc80075f1b1e6422021afb972dd11fd9088798b254cff3268068a7ae8786a29511440e7b716c6f48550671bebd772e34c6b509c96357f84
@@ -23,6 +23,18 @@ module Moxml
23
23
  CHILDREN_CAPACITY = 64
24
24
  private_constant :CHILDREN_CAPACITY
25
25
 
26
+ # #367: HTML-parsed trees carry no namespace declarations,
27
+ # so the engine's attribute-URI face answers nil for the
28
+ # RESERVED prefixes too (xml:lang loses its identity). The
29
+ # wrapper path resolves them from the builtin table
30
+ # (AttributeResolver) — the bulk stride mirrors that, so
31
+ # records and wrapper API agree on every tree flavor.
32
+ RESERVED_ATTR_PREFIX_URIS = {
33
+ "xml" => "http://www.w3.org/XML/1998/namespace",
34
+ "xmlns" => "http://www.w3.org/2000/xmlns/",
35
+ }.freeze
36
+ private_constant :RESERVED_ATTR_PREFIX_URIS
37
+
26
38
  # Bulk materialization (issues #132/#143): a Ruby-side
27
39
  # post-order recursion over RAW C pointers — no binding
28
40
  # wrapper per node, no per-node FFI callback, no depth memo
@@ -132,6 +144,7 @@ module Moxml
132
144
  # path's resolver semantics (moxml's canonical shape).
133
145
  attr_name = attr_name[(colon + 1)..]
134
146
  attr_uri = f.leptris_attribute_namespace_uri(attr)
147
+ attr_uri ||= RESERVED_ATTR_PREFIX_URIS[attr_prefix]
135
148
  else
136
149
  attr_prefix = nil
137
150
  attr_uri = nil
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.129"
4
+ VERSION = "0.5.130"
5
5
  end
@@ -0,0 +1,35 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "spec_helper"
4
+
5
+ # #367: the bulk records stride carries the bound namespace URI
6
+ # for RESERVED-prefixed attributes on HTML-fragment-parsed trees —
7
+ # HTML trees carry no declarations, so the engine's attribute-URI
8
+ # face answers nil for xml:lang there; the bulk path mirrors the
9
+ # wrapper resolver's builtin table so records and wrapper agree.
10
+ RSpec.describe "materialize_fields reserved-prefix URIs (#367)" do
11
+ let(:ctx) { Moxml.new(:leptris) }
12
+ let(:frag) { ctx.parse_html_fragment('<span lang="en" xml:lang="en">text</span>') }
13
+ let(:span) { frag.children.first }
14
+
15
+ def records_attrs
16
+ out = nil
17
+ span.materialize_fields do |kind, _q, _p, _u, _ns, attrs, _t, _d| # rubocop:disable Metrics/ParameterLists,Lint/UnusedBlockArgument
18
+ out = attrs.dup if kind == :element
19
+ end
20
+ out
21
+ end
22
+
23
+ it "matches the wrapper API for prefixed attributes on fragment trees" do
24
+ records = records_attrs
25
+ expect(records).to eq(
26
+ ["lang", "en", nil, nil,
27
+ "lang", "en", "http://www.w3.org/XML/1998/namespace", "xml"],
28
+ )
29
+ end
30
+
31
+ it "agrees with the wrapper attribute API stride-for-stride" do
32
+ wrapper = span.attributes.map { |a| [a.name, a.value, a.namespace&.uri, a.namespace&.prefix] }
33
+ expect(records_attrs.each_slice(4).to_a).to eq(wrapper)
34
+ end
35
+ 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.129
4
+ version: 0.5.130
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ribose Inc.
@@ -508,6 +508,7 @@ files:
508
508
  - spec/moxml/error_spec.rb
509
509
  - spec/moxml/html_fragment_spec.rb
510
510
  - spec/moxml/lazy_parse_spec.rb
511
+ - spec/moxml/materialize_namespace_uri_spec.rb
511
512
  - spec/moxml/materializer_spec.rb
512
513
  - spec/moxml/moxml_spec.rb
513
514
  - spec/moxml/namespace_spec.rb