Skip to content

Commit 7e92d65

Browse files
author
Brian Hall
committed
changed type compare to instanceof and added test
1 parent afe3c41 commit 7e92d65

File tree

2 files changed

+17
-1
lines changed

2 files changed

+17
-1
lines changed

shared/helpers/view.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ function getClientPlaceholder(viewName, viewOptions, Handlebars) {
6868
// create a list of data attributes
6969
var attrString = _.inject(viewOptions, function(memo, value, key) {
7070
if (_.isArray(value) || _.isObject(value)) {
71-
if (key === '_block' && value.contructor === Handlebars.SafeString) {
71+
if (key === '_block' && value instanceof Handlebars.SafeString) {
7272
value = value.string;
7373
} else {
7474
value = JSON.stringify(value);

test/shared/helpers/view.test.js

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -175,6 +175,22 @@ describe('view', function () {
175175
'<div data-render="true" data-generic_object="{&quot;a&quot;:1,&quot;b&quot;:2,&quot;c&quot;:3}" data-fetch_summary="{}" data-view="test"></div>'
176176
);
177177
});
178+
179+
context('when the key is _block and is of type Handlebars.SafeString', function () {
180+
it('extracts the string correctly', function () {
181+
var html = '<div>something</div>',
182+
result = subject.call({
183+
_app: app()
184+
}, 'test', {
185+
hash: {
186+
_block: new Handlebars.SafeString(html)
187+
}
188+
});
189+
expect(result.string).to.eq(
190+
'<div data-render="true" data-_block="&lt;div&gt;something&lt;/div&gt;" data-fetch_summary="{}" data-view="test"></div>'
191+
);
192+
});
193+
});
178194
});
179195
});
180196
});

0 commit comments

Comments
 (0)