-
-
Notifications
You must be signed in to change notification settings - Fork 4.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #17251 from rwjblue/remove-debug-with-assertion
[BUGFIX beta] Prevent errors with debug compiled templates in prod.
- Loading branch information
Showing
3 changed files
with
39 additions
and
54 deletions.
There are no files selected for viewing
46 changes: 23 additions & 23 deletions
46
packages/@ember/-internals/glimmer/lib/helpers/-assert-implicit-component-helper-argument.ts
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 |
---|---|---|
@@ -1,36 +1,36 @@ | ||
import { DEBUG } from '@glimmer/env'; | ||
import { Opaque } from '@glimmer/interfaces'; | ||
import { Tag, VersionedPathReference } from '@glimmer/reference'; | ||
import { Arguments, Helper, VM } from '@glimmer/runtime'; | ||
import { Maybe } from '@glimmer/util'; | ||
import { Arguments, VM } from '@glimmer/runtime'; | ||
|
||
let helper: Maybe<Helper> = undefined; | ||
class ComponentAssertionReference implements VersionedPathReference<Opaque> { | ||
public tag: Tag; | ||
|
||
if (DEBUG) { | ||
class ComponentAssertionReference implements VersionedPathReference<Opaque> { | ||
public tag: Tag; | ||
|
||
constructor(private component: VersionedPathReference<Opaque>, private message: string) { | ||
this.tag = component.tag; | ||
} | ||
|
||
value(): Opaque { | ||
let value = this.component.value(); | ||
constructor(private component: VersionedPathReference<Opaque>, private message: string) { | ||
this.tag = component.tag; | ||
} | ||
|
||
if (typeof value === 'string') { | ||
throw new TypeError(this.message); | ||
} | ||
value(): Opaque { | ||
let value = this.component.value(); | ||
|
||
return value; | ||
if (typeof value === 'string') { | ||
throw new TypeError(this.message); | ||
} | ||
|
||
get(property: string): VersionedPathReference<Opaque> { | ||
return this.component.get(property); | ||
} | ||
return value; | ||
} | ||
|
||
helper = (_vm: VM, args: Arguments) => | ||
new ComponentAssertionReference(args.positional.at(0), args.positional.at(1).value() as string); | ||
get(property: string): VersionedPathReference<Opaque> { | ||
return this.component.get(property); | ||
} | ||
} | ||
|
||
export default helper; | ||
export default (_vm: VM, args: Arguments) => { | ||
if (DEBUG) { | ||
return new ComponentAssertionReference(args.positional.at(0), args.positional | ||
.at(1) | ||
.value() as string); | ||
} else { | ||
return args.positional.at(0); | ||
} | ||
}; |
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