From a2efbce26da2e938eed1fb0aeb4f1fe956ea0f6b Mon Sep 17 00:00:00 2001 From: Vagner Lucas Date: Wed, 7 Sep 2016 19:59:13 -0300 Subject: [PATCH] Added .component support to angularAMD --- dist/angularAMD.js | 45 +++++++++++----- package.json | 85 +++++++++++++++--------------- src/angularAMD.js | 6 +++ test/conf/karma.unit.mustache | 1 + test/conf/karma.unit.no_ngload.js | 1 + test/unit/factory/utestProvider.js | 25 +++++++-- test/unit/lib/component.js | 17 ++++++ test/unit/lib/main.mustache | 1 + 8 files changed, 124 insertions(+), 57 deletions(-) create mode 100644 test/unit/lib/component.js diff --git a/dist/angularAMD.js b/dist/angularAMD.js index 56bd9a4..b80964c 100644 --- a/dist/angularAMD.js +++ b/dist/angularAMD.js @@ -1,8 +1,9 @@ -/*! - angularAMD v0.2.1 +/* + angularAMD v<%= cvars.proj_version %> (c) 2013-2014 Marcos Lin https://github.com/marcoslin/ License: MIT */ + define(function () { 'use strict'; var bootstrapped = false, @@ -95,6 +96,11 @@ define(function () { }; window.angular = alt_angular; + + if (require.defined('angular')) { + require.undef('angular'); + define('angular', [], alt_angular); + } } // Constructor @@ -189,15 +195,16 @@ define(function () { if (typeof alt_angular === 'undefined') { throw new Error('Alternate angular not set. Make sure that `enable_ngload` option has been set when calling angularAMD.bootstrap'); } - + // Process alternate queue in FIFO fashion function processRunBlock(block) { //console.info('"' + item.name + '": executing run block: ', run_block); run_injector.invoke(block); } - while (alternate_queue.length) { - var item = alternate_queue.shift(), + // Process the config blocks + for (var i=0;i'); + element = $compile(element)(scope); + scope.prop = 'loaded'; + scope.$digest(); + }) + }); + + it(".component check.", function() { + var h3 = element.find('h3'); + expect(h3.text()).toBe('Component Title loaded'); + }); + }) }; }); \ No newline at end of file diff --git a/test/unit/lib/component.js b/test/unit/lib/component.js new file mode 100644 index 0000000..c4c53d8 --- /dev/null +++ b/test/unit/lib/component.js @@ -0,0 +1,17 @@ +define(['app', 'angularAMD'], function (app, angularAMD) { + var comp_name = "mainComponent"; + + // console.log('component called'); + + app.component(comp_name, { + bindings: { + compBind: '@' + }, + controller: function() { + this.title = 'Component Title'; + }, + template: '

{{ $ctrl.title }} {{ $ctrl.compBind }}

' + }); + + return this; +}); diff --git a/test/unit/lib/main.mustache b/test/unit/lib/main.mustache index f696326..1f104db 100644 --- a/test/unit/lib/main.mustache +++ b/test/unit/lib/main.mustache @@ -19,6 +19,7 @@ 'services': 'test/unit/lib/services', 'regServices': 'test/unit/lib/regServices', 'controller': 'test/unit/lib/controller', + 'component' : 'test/unit/lib/component', 'regController': 'test/unit/lib/regController', 'decoServices': 'test/unit/lib/decoServices' },