From 9fb29cce5ea5f67c43d2aa5926a4f7a8aa4ba81c Mon Sep 17 00:00:00 2001 From: c0bra Date: Tue, 7 Oct 2014 09:00:00 -0500 Subject: [PATCH] fix(uiGridCell): Use promises for tmpl processing Issue #1712 demonstrates a race condition where a column's compiledElementFn is attempted to be called before the cellTemplate is present, e.g. in the case of a template fetched over the network. This causes the function to not be present and an exception to be thrown. This changes fixes this by added a getCompiledElementFn() method to GridColumn, which returns a promise that is created in the defaultColumnBuilder(). It gets resolved in Grid.preCompileCellTemplates(). uiGridCell now uses this promise if the function is not present at pre-link time. Added tests for getCompiledElementFn() and getCellTemplate() Fixes #1712 --- misc/demo/cellTemplate.html | 3 + misc/demo/grid-directive.html | 14 ++- src/js/core/directives/ui-grid-cell.js | 13 ++- src/js/core/factories/Grid.js | 4 + src/js/core/factories/GridColumn.js | 12 ++ src/js/core/services/gridClassFactory.js | 8 +- test/unit/core/factories/GridColumn.spec.js | 116 +++++++++++++++++++- 7 files changed, 160 insertions(+), 10 deletions(-) create mode 100644 misc/demo/cellTemplate.html diff --git a/misc/demo/cellTemplate.html b/misc/demo/cellTemplate.html new file mode 100644 index 0000000000..ce7160826e --- /dev/null +++ b/misc/demo/cellTemplate.html @@ -0,0 +1,3 @@ +
+ Testing $http template: {{COL_FIELD CUSTOM_FILTERS}} +
\ No newline at end of file diff --git a/misc/demo/grid-directive.html b/misc/demo/grid-directive.html index 9d5bfdeceb..9cb57699e8 100644 --- a/misc/demo/grid-directive.html +++ b/misc/demo/grid-directive.html @@ -46,12 +46,20 @@

Grid