Ticket #15 (closed enhancement: fixed)

Opened 3 years ago

Last modified 2 years ago

Element#clone should be changed to support decendent classes

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

Description

Element#clone is current defined as

Element.new self

This has limited usefulness when self is actually a descendent of Element. The descendent class could of course also redefine clone but if Element#clone was defined as:

self.class.new self

Then the cloned object would automatically have the same class as self such that:

class MyElement < Element; end

e = Myelement.new 'foo'
other = e.clone
other.class        # -> MyElement (instead of Element)

would work as described.

BTW: Thanks for making REXML available!

Change History

Changed 3 years ago by anonymous

  • milestone changed from 3.1.4 to 3.1.6

Changed 2 years ago by ser

  • status changed from new to closed
  • resolution set to fixed

Implemented proposed fix.

Note: See TracTickets for help on using tickets.