Ticket #155 (new defect)

Opened 4 months ago

Last modified 4 months ago

[PATCH] REXML::Element#delete_attribute not behaving correctly

Reported by: fbuilesv Owned by: ser
Priority: normal Milestone:
Component: DOM Version: 3.1.6
Severity: normal Keywords:
Cc: fbuilesv Ruby version: 1.8.6
Operating system: MacOS

Description

Detailed description

According to the REXML::Element#delete_attribute docs, it should be able to receive either a String or an Attribute and then proceed to delete it if it exists. This is currently failing when it receives an Attributes as the parameter:

e = REXML::Element.new("foo")

=> <foo/>

a = REXML::Attribute.new("bar", "bla")

=> bar='bla'

e.add_attribute(a)

=> bar='bla'

e.delete_attribute(a)

=> nil

e.attributes

=> {"bar"=>bar='bla'} # attribute was not removed

The attached patch fixes it by making sure it passes only the Attribute's name to Attributes#get_attributes.

Attachments

fix_rexml_delete_attribut.patch (1.0 kB) - added by fbuilesv 4 months ago.
Patch for delete_attribute and a small doc fix.

Change History

Changed 4 months ago by fbuilesv

Patch for delete_attribute and a small doc fix.

Changed 4 months ago by fbuilesv

  • cc fbuilesv added

Also, the patch fixes a small error on the docs, the return value mentioned says it returns the deleted attribute but the examples and the behavior show that it returns the element with the attribute removed.

Note: See TracTickets for help on using tickets.