Uploaded image for project: 'Groovy'
  1. Groovy
  2. GROOVY-2547

Parent is still set in Node after removing it from the tree

    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Closed
    • Minor
    • Resolution: Fixed
    • 1.5.1
    • 1.6-rc-1, 1.5.8, 1.7-beta-1
    • None
    • None

    Description

      I haven't found docs about removing groovy.util.Node but this seems kind of wrong. I can remove a node but the parent of this node is still the old parent.

      def xml = '''
      <foo>
          <bar id="1" />
          <bar id="2" />
          <bar id="3" />
      </foo>'''
      Node foo = new XmlParser().parseText(xml)
      
      assert foo.bar.size() == 3
      
      Node bar2 = foo.bar.find {it.@id == '2'}
      bar2.parent().children().remove(bar2)
      
      assert foo.bar.size() == 2
      assert ! foo.bar.contains(bar2)
      
      assert bar2.parent() == null // this fails
      

      Attachments

        Activity

          People

            paulk Paul King
            doubleday Daniel Doubleday
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: