Closed
Labels
Description
Docx::Elements::Element#prepend_to calls element.node.properties. That method doesn't exist on a Nokogiri node, so every call raises.
# lib/docx/elements/element.rb
def prepend_to(element)
@node = element.node.properties.add_next_sibling(@node)
self
endRepro
w = 'http://schemas.openxmlformats.org/wordprocessingml/2006/main'
body = Nokogiri::XML(%(<w:body xmlns:w="#{w}"><w:p><w:pPr/></w:p><w:r><w:t>x</w:t></w:r></w:body>)).root
para = Docx::Elements::Containers::Paragraph.new(body.at_xpath('w:p'))
run = Docx::Elements::Containers::TextRun.new(body.at_xpath('w:r'))
run.prepend_to(para)
# => NoMethodError: undefined method 'properties' for an instance of Nokogiri::XML::ElementExpected: the node is inserted as the first child of element, after its properties node (w:pPr etc.) if there is one. That is probably element.properties (the Container method) rather than element.node.properties, with a fallback to prepend_child when there are no properties.
Found while splitting the specs into per-class unit specs (#188).
Activity