Skip to content
This repository has been archived by the owner on Apr 12, 2024. It is now read-only.

fix($interpolate): don't ReferenceError when context is undefined #7237

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/ng/interpolate.js
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ function $InterpolateProvider() {
};

return extend(function interpolationFn(context) {
var scopeId = context.$id || 'notAScope';
var scopeId = (context && context.$id) || 'notAScope';
var lastValues = lastValuesCache.values[scopeId];
var lastResult = lastValuesCache.results[scopeId];
var i = 0;
Expand All @@ -214,7 +214,7 @@ function $InterpolateProvider() {
if (!lastValues) {
lastValues = [];
inputsChanged = true;
if (context.$on) {
if (context && context.$on) {
context.$on('$destroy', function() {
lastValuesCache.values[scopeId] = null;
lastValuesCache.results[scopeId] = null;
Expand Down
5 changes: 5 additions & 0 deletions test/ng/interpolateSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,11 @@ describe('$interpolate', function() {
}));


it('should interpolate with undefined context', inject(function($interpolate) {
expect($interpolate("Hello, world!{{bloop}}")()).toBe("Hello, world!");
}));


describe('interpolating in a trusted context', function() {
var sce;
beforeEach(function() {
Expand Down