UNPKG

jw-ng-forward

Version:

Temporary package. The default solution for those that want to write Angular 2.x style code in Angular 1.x

113 lines (112 loc) 3.83 kB
"use strict"; var __read = (this && this.__read) || function (o, n) { var m = typeof Symbol === "function" && o[Symbol.iterator]; if (!m) return o; var i = m.call(o), r, ar = [], e; try { while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value); } catch (error) { e = { error: error }; } finally { try { if (r && !r.done && (m = i["return"])) m.call(i); } finally { if (e) throw e.error; } } return ar; }; var __spread = (this && this.__spread) || function () { for (var ar = [], i = 0; i < arguments.length; i++) ar = ar.concat(__read(arguments[i])); return ar; }; var __importStar = (this && this.__importStar) || function (mod) { if (mod && mod.__esModule) return mod; var result = {}; if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k]; result["default"] = mod; return result; }; Object.defineProperty(exports, "__esModule", { value: true }); var angular = __importStar(require("angular")); var writers_1 = require("../writers"); var get_injectable_name_1 = require("./get-injectable-name"); var By = (function () { function By() { } By.all = function () { return '*'; }; By.css = function (selector) { return selector; }; By.directive = function (type) { return writers_1.bundleStore.get('selector', type); }; return By; }()); exports.By = By; (function extendJQLite(proto) { Object.defineProperties(proto, { nativeElement: { get: function () { return this[0]; }, }, componentInstance: { get: function () { if (this._componentInstance) return this._componentInstance; var isolateScope = this.isolateScope(); this._componentInstance = isolateScope && isolateScope['ctrl'] || null; return this._componentInstance; }, }, componentViewChildren: { get: function () { return __spread(this.children()).map(function (child) { return angular.element(child); }); }, }, getLocal: { value: function (injectable) { return (this.injector() || this.inheritedData('$injector')) .get(get_injectable_name_1.getInjectableName(injectable)); }, }, query: { value: function (predicate, scope) { var results = this.queryAll(predicate, scope); return results.length > 0 ? results[0] : null; }, }, queryAll: { value: function (predicate, scope) { if (scope) throw Error('scope argument not yet supported. All queries are done with Scope.all for now.'); return Array .from(this[0].querySelectorAll(predicate)) .map(function (el) { return angular.element(el); }); }, }, getDirectiveInstance: { value: function (index) { throw new Error('Not yet implemented in ng-forward.'); }, }, triggerEventHandler: { value: function (eventName, eventObj) { throw new Error('Not yet implemented in ng-forward.'); }, }, inject: { value: function (type) { throw new Error('Not yet implemented in ng-forward.'); }, }, hasDirective: { value: function (type) { throw new Error('Not yet implemented in ng-forward.'); }, }, }); })(angular.element.prototype); exports.default = angular.element;