Skip to content

Commit

Permalink
Merge pull request #18148 from buschtoens/17486-fix-template-if-empty…
Browse files Browse the repository at this point in the history
…-htmlSafe

[BUGFIX beta] fix(glimmer/utils/to-bool): `htmlSafe`
  • Loading branch information
locks authored Dec 4, 2020
2 parents b61aa6e + f94de89 commit bcb0a49
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
3 changes: 3 additions & 0 deletions packages/@ember/-internals/glimmer/lib/utils/to-bool.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { isHTMLSafe } from '@ember/-internals/glimmer';
import { get, tagForProperty } from '@ember/-internals/metal';
import { isArray } from '@ember/-internals/runtime';
import { isProxy } from '@ember/-internals/utils';
Expand All @@ -12,6 +13,8 @@ export default function toBool(predicate: unknown): boolean {
consumeTag(tagForProperty(predicate as object, '[]'));

return (predicate as { length: number }).length !== 0;
} else if (isHTMLSafe(predicate)) {
return Boolean(predicate.toString());
} else {
return Boolean(predicate);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import { RenderingTestCase, applyMixins, runTask } from 'internal-test-helpers';

import { assign } from '@ember/polyfills';
import { htmlSafe } from '@ember/-internals/glimmer';
import { get, set } from '@ember/-internals/metal';
import {
Object as EmberObject,
Expand Down Expand Up @@ -408,6 +409,7 @@ const IfUnlessWithTestCases = [
new Boolean(true),
new Boolean(false),
new Date(),
htmlSafe(' '),
]),

new StableFalsyGenerator([
Expand All @@ -419,6 +421,7 @@ const IfUnlessWithTestCases = [
[],
emberA(),
ObjectProxy.create({ content: undefined }),
htmlSafe(''),
]),

new ObjectProxyGenerator([
Expand Down

0 comments on commit bcb0a49

Please sign in to comment.