Fixes #2182 - Element.erase('html') should set the innerHTML to an empty string #2187

Merged
merged 1 commit into from Jan 7, 2012
Jump to file or symbol
Failed to load files and symbols.
+9 −0
Split
@@ -920,6 +920,7 @@ Element.Properties.html = (function(){
var html = {
set: function(html){
if (typeOf(html) == 'array') html = html.join('');
+ else if (!html) html = '';

This comment has been minimized.

Show comment Hide comment
@ibolmo

ibolmo Dec 24, 2011

Owner

should we check for html == undefined reason being false, 0, and any toValue that returns falsy

@ibolmo

ibolmo Dec 24, 2011

Owner

should we check for html == undefined reason being false, 0, and any toValue that returns falsy

This comment has been minimized.

Show comment Hide comment
@arian

arian Dec 24, 2011

Owner

hm, yeah, probably if (html == null) html = ''; would be better...

@arian

arian Dec 24, 2011

Owner

hm, yeah, probably if (html == null) html = ''; would be better...

var wrap = (!tableTest && translations[this.get('tag')]);
/*<ltIE9>*/
@@ -162,6 +162,14 @@ describe('Element', function(){
});
+ describe("Element.erase('html')", function(){
+
+ it('should empty the html inside an element', function(){
+ expect(new Element('div', {html: '<p>foo bar</p>'}).erase('html').innerHTML).toEqual('');
+ });
+
+ });
+
describe('Element.clone', function(){
it('should not crash IE for multiple clones', function(){