UNPKG

2.89 kBJavaScriptView Raw
1var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
2 var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3 if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
4 else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
5 return c > 3 && r && Object.defineProperty(target, key, r), r;
6};
7define(["require", "exports", "aurelia-templating", "aurelia-logging"], function (require, exports, aurelia_templating_1, aurelia_logging_1) {
8 "use strict";
9 Object.defineProperty(exports, "__esModule", { value: true });
10 /**
11 * Attribute to be placed on any HTML element in a view to emit the View instance
12 * to the debug console, giving you insight into the live View instance, including
13 * all child views, live bindings, behaviors and more.
14 */
15 var ViewSpy = /** @class */ (function () {
16 /**
17 * Creates a new instance of ViewSpy.
18 */
19 function ViewSpy() {
20 this.logger = aurelia_logging_1.getLogger('view-spy');
21 }
22 ViewSpy.prototype._log = function (lifecycleName, context) {
23 if (!this.value && lifecycleName === 'created') {
24 this.logger.info(lifecycleName, this.view);
25 }
26 else if (this.value && this.value.indexOf(lifecycleName) !== -1) {
27 this.logger.info(lifecycleName, this.view, context);
28 }
29 };
30 /**
31 * Invoked when the target view is created.
32 * @param view The target view.
33 */
34 ViewSpy.prototype.created = function (view) {
35 this.view = view;
36 this._log('created');
37 };
38 /**
39 * Invoked when the target view is bound.
40 * @param bindingContext The target view's binding context.
41 */
42 ViewSpy.prototype.bind = function (bindingContext) {
43 this._log('bind', bindingContext);
44 };
45 /**
46 * Invoked when the target element is attached to the DOM.
47 */
48 ViewSpy.prototype.attached = function () {
49 this._log('attached');
50 };
51 /**
52 * Invoked when the target element is detached from the DOM.
53 */
54 ViewSpy.prototype.detached = function () {
55 this._log('detached');
56 };
57 /**
58 * Invoked when the target element is unbound.
59 */
60 ViewSpy.prototype.unbind = function () {
61 this._log('unbind');
62 };
63 ViewSpy = __decorate([
64 aurelia_templating_1.customAttribute('view-spy')
65 ], ViewSpy);
66 return ViewSpy;
67 }());
68 exports.ViewSpy = ViewSpy;
69});