forked from emberjs/ember.js
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[BUGFIX beta] Deprecate escaped style attributes.
- Loading branch information
Showing
4 changed files
with
96 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
import EmberView from "ember-views/views/view"; | ||
import compile from "ember-template-compiler/system/compile"; | ||
import { SafeString } from "ember-htmlbars/utils/string"; | ||
import { runAppend, runDestroy } from "ember-runtime/tests/utils"; | ||
|
||
var view; | ||
|
||
QUnit.module("ember-htmlbars: style attribute", { | ||
teardown() { | ||
runDestroy(view); | ||
} | ||
}); | ||
|
||
if (Ember.FEATURES.isEnabled('ember-htmlbars-attribute-syntax')) { | ||
// jscs:disable validateIndentation | ||
|
||
QUnit.test('specifying `<div style="width: {{userValue}}></div>` is [DEPRECATED]', function() { | ||
view = EmberView.create({ | ||
userValue: '42', | ||
template: compile('<div style="width: {{view.userValue}}"></div>') | ||
}); | ||
|
||
expectDeprecation(function() { | ||
runAppend(view); | ||
}, /Dynamic content in the `style` attribute is not escaped and may pose a security risk. Please preform a security audit and once verified change from `<div style="foo: {{property}}">` to `<div style="foo: {{{property}}}">/); | ||
}); | ||
|
||
QUnit.test('specifying `<div style="width: {{{userValue}}}></div>` works properly', function() { | ||
view = EmberView.create({ | ||
userValue: '42', | ||
template: compile('<div style="width: {{view.userValue}}"></div>') | ||
}); | ||
|
||
expectNoDeprecation(function() { | ||
runAppend(view); | ||
}); | ||
}); | ||
|
||
QUnit.test('specifying `<div style="width: {{userValue}}></div>` works properly with a SafeString', function() { | ||
view = EmberView.create({ | ||
userValue: new SafeString('42'), | ||
template: compile('<div style="width: {{view.userValue}}"></div>') | ||
}); | ||
|
||
expectNoDeprecation(function() { | ||
runAppend(view); | ||
}); | ||
}); | ||
|
||
// jscs:enable validateIndentation | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters