Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

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

Merged
merged 1 commit into from

2 participants

@arian
Owner

Element.properties.html.erase was aliased to Element.properties.html.set, but when calling it without any arguments this resulted in .set(undefined).

See #2182

@arian arian Fixes #2182 - Element.erase('html') should set the innerHTML to an em…
…pty string.

Element.properties.html.erase was aliased to Element.properties.html.set, but when calling it without any arguments this resulted in .set(undefined).
4adb41a
@ibolmo ibolmo commented on the diff
Source/Element/Element.js
@@ -920,6 +920,7 @@ Element.Properties.html = (function(){
var html = {
set: function(html){
if (typeOf(html) == 'array') html = html.join('');
+ else if (!html) html = '';
@ibolmo Owner
ibolmo added a note

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

@arian Owner
arian added a note

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
@ibolmo
Owner

:+1: I'll manually update the check.

@ibolmo ibolmo merged commit 4086f20 into mootools:master
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Dec 24, 2011
  1. @arian

    Fixes #2182 - Element.erase('html') should set the innerHTML to an em…

    arian authored
    …pty string.
    
    Element.properties.html.erase was aliased to Element.properties.html.set, but when calling it without any arguments this resulted in .set(undefined).
This page is out of date. Refresh to see the latest.
Showing with 9 additions and 0 deletions.
  1. +1 −0  Source/Element/Element.js
  2. +8 −0 Specs/1.4client/Element/Element.js
View
1  Source/Element/Element.js
@@ -920,6 +920,7 @@ Element.Properties.html = (function(){
var html = {
set: function(html){
if (typeOf(html) == 'array') html = html.join('');
+ else if (!html) html = '';
@ibolmo Owner
ibolmo added a note

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

@arian Owner
arian added a note

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
var wrap = (!tableTest && translations[this.get('tag')]);
/*<ltIE9>*/
View
8 Specs/1.4client/Element/Element.js
@@ -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(){
Something went wrong with that request. Please try again.