mojo icon indicating copy to clipboard operation
mojo copied to clipboard

Mojo::DOM should have a ->remove method

Open berle opened this issue 14 years ago • 10 comments

At this point, some bright person will probably comment that "Butbutbut you can like use ->replace for that". Yes, I know, but there's a difference. Imagine implementing a CRUD interface to a database and skipping the D because it can be implemented by passing an empty document to U. How would that feel to you? Perhaps a bit inelegant? That's the same feeling people get when looking at using ->replace to delete data, albeit on a somewhat smaller scale.

berle avatar Jun 01 '12 22:06 berle

I'm neutral on this, both arguments make sense.

kraih avatar Jun 01 '12 22:06 kraih

+1

tempire avatar Jun 01 '12 22:06 tempire

-1

Changing my vote since i don't like the inconsistency between $dom->remove and $dom->replace_content('').

kraih avatar Jun 02 '12 12:06 kraih

I like ->remove because it's obvious when that's what your intent is. Is there really a high maintenance cost to an additional subroutine? Seems like something that would require almost no effort after it's initially written.

tempire avatar Jun 02 '12 20:06 tempire

There sure is additional maintenance cost, for example all new tests for $dom->replace('') will have to be written twice.

kraih avatar Jun 02 '12 20:06 kraih

Does remove have to be any more than a call to $dom->replace('')?

tempire avatar Jun 02 '12 20:06 tempire

Nope, not at the moment.

kraih avatar Jun 02 '12 20:06 kraih

-1 from me as well, agree with @kraih

marcusramberg avatar Jun 02 '12 21:06 marcusramberg

I'm afraid this proposal has been rejected by majority vote.

kraih avatar Jun 03 '12 20:06 kraih

Testing this feature atm., not sure if it will stay though. https://github.com/kraih/mojo/commit/ec77b0ee7c349643d686e56b107d9364a3697829

kraih avatar Jul 23 '12 09:07 kraih