Skip to content

TextRun#text= on a run without w:t leaves #text stale #190

Closed

Description

@satoryu

When a run has no w:t, TextRun#text= creates one and writes the content into the XML. But @text_nodes isn't refreshed, so #text (and #to_s, #to_html) still returns "".

Repro

w = 'http://schemas.openxmlformats.org/wordprocessingml/2006/main'
run = Docx::Elements::Containers::TextRun.new(Nokogiri::XML(%(<w:r xmlns:w="#{w}"/>)).root)
run.text = 'new'
run.text       # => ""     (expected "new")
run.node.text  # => "new"

Runs created through TextRun.create_with / create_within start out like this, so anything that sets their text and then reads the same object back sees the stale value.

Expected: #text returns "new". For example, text= could append the new Elements::Text to @text_nodes before reset_text.

Found while splitting the specs into per-class unit specs (#188).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions