Skip to content

Commit

Permalink
Merge pull request #12686 from bekzod/html-safe-none
Browse files Browse the repository at this point in the history
[BUGFIX beta] htmlsafe warning not thrown for none values
  • Loading branch information
rwjblue committed Dec 6, 2015
2 parents 3f4db6f + 32e7fee commit 3561214
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 1 deletion.
3 changes: 2 additions & 1 deletion packages/ember-htmlbars/lib/morphs/attr-morph.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { warn, debugSeal } from 'ember-metal/debug';
import DOMHelper from 'dom-helper';
import isNone from 'ember-metal/is_none';

var HTMLBarsAttrMorph = DOMHelper.prototype.AttrMorphClass;

Expand All @@ -22,7 +23,7 @@ function deprecateEscapedStyle(morph, value) {
styleWarning,
(function(name, value, escaped) {
// SafeString
if (value && value.toHTML) {
if (isNone(value) || (value && value.toHTML)) {
return true;
}

Expand Down
21 changes: 21 additions & 0 deletions packages/ember-htmlbars/tests/attr_nodes/style_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,3 +71,24 @@ QUnit.test('specifying `<div style={{userValue}}></div>` works properly with a S

deepEqual(warnings, [ ]);
});

QUnit.test('null value do not generate htmlsafe warning', function() {
view = EmberView.create({
userValue: null,
template: compile('<div style={{view.userValue}}></div>')
});

runAppend(view);

deepEqual(warnings, [ ]);
});

QUnit.test('undefined value do not generate htmlsafe warning', function() {
view = EmberView.create({
template: compile('<div style={{view.userValue}}></div>')
});

runAppend(view);

deepEqual(warnings, [ ]);
});

0 comments on commit 3561214

Please sign in to comment.