Skip to content

Commit 069789c

Browse files
fix(viewDirective): Use extend() to keep a private copy of ViewConfigs instead of angular.copy()
fix(view): Fixed broken phantomJS due to template string including double quotes (typescript transpiles this wrong currently)
1 parent 0dee6fb commit 069789c

File tree

2 files changed

+15
-10
lines changed

2 files changed

+15
-10
lines changed

src/view/view.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,10 @@ interface ViewKey {
1111
item: any
1212
}
1313

14-
const debug = noop;
15-
//const debug = function() { console.log.call(console, arguments); };
14+
const _debug = false;
15+
const debug = function(...any) {
16+
if (_debug) { console.log.call(console, arguments); }
17+
};
1618

1719
const viewKey = (item: any) =>
1820
extend(pick(item, "name", "context", "parentContext"), { item: item });
@@ -202,7 +204,7 @@ function $View( $rootScope, $templateFactory, $q, $timeout) {
202204
this.registerUiView = function register(uiView) {
203205
var fqnMatches = isEq(prop("fqn"), val(uiView.fqn));
204206
if (uiViews.filter(fqnMatches).length)
205-
debug(`uiView already exists with name: "${uiView.fqn}" (named ${uiView.name} in context ${uiView.context})`);
207+
debug(`uiView already exists with name: '${uiView.fqn}' (named ${uiView.name} in context ${uiView.context})`);
206208

207209
uiViews.push(uiView);
208210
this.sync();

src/view/viewDirective.ts

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,11 @@ import {parse, extend, isDefined, isString, noop} from "../common/common";
44
import {annotateController} from "../common/angular1";
55
import {ViewConfig} from "./view"
66

7-
const debug = noop;
8-
//const debug = function() { console.log.apply(console, arguments); };
7+
//const debug = noop;
8+
const _debug = false;
9+
const debug = function(...any) {
10+
if (_debug) { console.log.apply(console, arguments); }
11+
};
912

1013
/**
1114
* @ngdoc directive
@@ -163,10 +166,10 @@ function $ViewDirective( $view, $animate, $uiViewScroll, $interpolate) {
163166
inherited = $element.inheritedData('$uiView') || { context: $view.rootContext() },
164167
name = $interpolate(attrs.uiView || attrs.name || '')(scope) || '$default';
165168

166-
function configUpdatedCallback(config) {
169+
function configUpdatedCallback(config: ViewConfig) {
167170
if (configsEqual(viewConfig, config)) return;
168-
debug(`Updating uiView "${viewData.fqn}" (${viewData.name} in context=${viewData.context}/parent=${viewData.parentContext}) with new config template "${config.template}"`);
169-
viewConfig = angular.copy(config);
171+
debug(`Updating uiView '${viewData.fqn}' (${viewData.name} in context=${viewData.context}/parent=${viewData.parentContext}) with new config template '${config.template}'`);
172+
viewConfig = extend({}, config);
170173
updateView(config);
171174
}
172175

@@ -185,7 +188,7 @@ function $ViewDirective( $view, $animate, $uiViewScroll, $interpolate) {
185188

186189
unregister = $view.registerUiView(viewData);
187190
scope.$on("$destroy", function() {
188-
debug(`Destroying uiView "${viewData.fqn}" (${viewData.name} in context=${viewData.context}/parent=${viewData.parentContext})`);
191+
debug(`Destroying uiView '${viewData.fqn}' (${viewData.name} in context=${viewData.context}/parent=${viewData.parentContext})`);
189192
unregister();
190193
});
191194

@@ -274,7 +277,7 @@ function $ViewDirectiveFill ( $compile, $controller, $interpolate, $injec
274277

275278
$element.html(data.$template || initial);
276279

277-
debug(`Fill: ${data.fqn}: Element contents: "${$element.html()}"`);
280+
debug(`Fill: ${data.fqn}: Element contents: '${$element.html()}'`);
278281
var link = $compile($element.contents());
279282
var controller = data.$controller;
280283
var controllerAs = data.$controllerAs;

0 commit comments

Comments
 (0)