All files / src/services control-name-resolver-service.js

0% Statements 0/20
0% Branches 0/16
0% Functions 0/4
0% Lines 0/20
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33                                                                 
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const aurelia_framework_1 = require("aurelia-framework");
class ControlNameResolverService {
    constructor() {
        this.nameCache = [];
    }
    getNameForControl(control, eachModule = aurelia_framework_1.PLATFORM.eachModule) {
        let found = null;
        if (!control || !control.name || !control.name.length) {
            return null;
        }
        if (this.nameCache[control.name] !== undefined) {
            return this.nameCache[control.name];
        }
        eachModule((m, v) => {
            if (v[control.name] === control)
                found = m;
            return true;
        });
        if (!found) {
            eachModule((m, v) => {
                if (v[control.name] && v[control.name].name === control.name)
                    found = m;
                return true;
            });
        }
        this.nameCache[control.name] = found;
        return found;
    }
}
exports.ControlNameResolverService = ControlNameResolverService;
//# sourceMappingURL=control-name-resolver-service.js.map