diff --git a/bower.json b/bower.json index a4b34a88..2ed17845 100644 --- a/bower.json +++ b/bower.json @@ -1,6 +1,6 @@ { "name": "aurelia-templating", - "version": "0.8.12", + "version": "0.8.13", "description": "An extensible HTML templating engine supporting databinding, custom elements, attached behaviors and more.", "keywords": [ "aurelia", diff --git a/dist/amd/animator.js b/dist/amd/animator.js new file mode 100644 index 00000000..c17fed25 --- /dev/null +++ b/dist/amd/animator.js @@ -0,0 +1,92 @@ +define(["exports"], function (exports) { + "use strict"; + + var _prototypeProperties = function (child, staticProps, instanceProps) { if (staticProps) Object.defineProperties(child, staticProps); if (instanceProps) Object.defineProperties(child.prototype, instanceProps); }; + + var _classCallCheck = function (instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }; + + var Animator = exports.Animator = (function () { + function Animator() { + _classCallCheck(this, Animator); + + Animator.instance = this; + this.animationStack = []; + } + + _prototypeProperties(Animator, null, { + addMultipleEventListener: { + value: function addMultipleEventListener(el, s, fn) { + var evts = s.split(" "), + i, + ii; + + for (i = 0, ii = evts.length; i < ii; ++i) { + el.addEventListener(evts[i], fn, false); + } + }, + writable: true, + configurable: true + }, + addAnimationToStack: { + value: function addAnimationToStack(animId) { + if (this.animationStack.indexOf(animId) < 0) { + this.animationStack.push(animId); + } + }, + writable: true, + configurable: true + }, + removeAnimationFromStack: { + value: function removeAnimationFromStack(animId) { + var idx = this.animationStack.indexOf(animId); + if (idx > -1) { + this.animationStack.splice(idx, 1); + } + }, + writable: true, + configurable: true + }, + move: { + value: function move() { + return Promise.resolve(false); + }, + writable: true, + configurable: true + }, + enter: { + value: function enter(element) { + return Promise.resolve(false); + }, + writable: true, + configurable: true + }, + leave: { + value: function leave(element) { + return Promise.resolve(false); + }, + writable: true, + configurable: true + }, + removeClass: { + value: function removeClass(element, className) { + return Promise.resolve(false); + }, + writable: true, + configurable: true + }, + addClass: { + value: function addClass(element, className) { + return Promise.resolve(false); + }, + writable: true, + configurable: true + } + }); + + return Animator; + })(); + + Object.defineProperty(exports, "__esModule", { + value: true + }); +}); \ No newline at end of file diff --git a/dist/amd/attached-behavior.js b/dist/amd/attached-behavior.js index 1b71fd01..07b459c0 100644 --- a/dist/amd/attached-behavior.js +++ b/dist/amd/attached-behavior.js @@ -5,12 +5,17 @@ define(["exports", "aurelia-metadata", "./behavior-instance", "./behaviors", "./ var _inherits = function (subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) subClass.__proto__ = superClass; }; + var _classCallCheck = function (instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }; + var ResourceType = _aureliaMetadata.ResourceType; var BehaviorInstance = _behaviorInstance.BehaviorInstance; var configureBehavior = _behaviors.configureBehavior; var hyphenate = _util.hyphenate; + var AttachedBehavior = exports.AttachedBehavior = (function (ResourceType) { function AttachedBehavior(attribute) { + _classCallCheck(this, AttachedBehavior); + this.name = attribute; this.properties = []; this.attributes = {}; @@ -80,5 +85,8 @@ define(["exports", "aurelia-metadata", "./behavior-instance", "./behaviors", "./ return AttachedBehavior; })(ResourceType); - exports.__esModule = true; + + Object.defineProperty(exports, "__esModule", { + value: true + }); }); \ No newline at end of file diff --git a/dist/amd/behavior-instance.js b/dist/amd/behavior-instance.js index 1e288b72..bacb7279 100644 --- a/dist/amd/behavior-instance.js +++ b/dist/amd/behavior-instance.js @@ -3,8 +3,12 @@ define(["exports"], function (exports) { var _prototypeProperties = function (child, staticProps, instanceProps) { if (staticProps) Object.defineProperties(child, staticProps); if (instanceProps) Object.defineProperties(child.prototype, instanceProps); }; + var _classCallCheck = function (instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }; + var BehaviorInstance = exports.BehaviorInstance = (function () { function BehaviorInstance(behavior, executionContext, instruction) { + _classCallCheck(this, BehaviorInstance); + this.behavior = behavior; this.executionContext = executionContext; @@ -112,5 +116,8 @@ define(["exports"], function (exports) { return BehaviorInstance; })(); - exports.__esModule = true; + + Object.defineProperty(exports, "__esModule", { + value: true + }); }); \ No newline at end of file diff --git a/dist/amd/behaviors.js b/dist/amd/behaviors.js index 081a00ac..a4b810b0 100644 --- a/dist/amd/behaviors.js +++ b/dist/amd/behaviors.js @@ -8,6 +8,7 @@ define(["exports", "aurelia-metadata", "aurelia-task-queue", "aurelia-binding", var ChildObserver = _children.ChildObserver; var BehaviorProperty = _property.BehaviorProperty; var hyphenate = _util.hyphenate; + function configureBehavior(container, behavior, target, valuePropertyName) { var proto = target.prototype, taskQueue = container.get(TaskQueue), @@ -63,5 +64,8 @@ define(["exports", "aurelia-metadata", "aurelia-task-queue", "aurelia-binding", behavior.childExpression = meta.first(ChildObserver); } - exports.__esModule = true; + + Object.defineProperty(exports, "__esModule", { + value: true + }); }); \ No newline at end of file diff --git a/dist/amd/binding-language.js b/dist/amd/binding-language.js index 80838322..a6b434d6 100644 --- a/dist/amd/binding-language.js +++ b/dist/amd/binding-language.js @@ -3,8 +3,12 @@ define(["exports"], function (exports) { var _prototypeProperties = function (child, staticProps, instanceProps) { if (staticProps) Object.defineProperties(child, staticProps); if (instanceProps) Object.defineProperties(child.prototype, instanceProps); }; + var _classCallCheck = function (instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }; + var BindingLanguage = exports.BindingLanguage = (function () { - function BindingLanguage() {} + function BindingLanguage() { + _classCallCheck(this, BindingLanguage); + } _prototypeProperties(BindingLanguage, null, { inspectAttribute: { @@ -32,5 +36,8 @@ define(["exports"], function (exports) { return BindingLanguage; })(); - exports.__esModule = true; + + Object.defineProperty(exports, "__esModule", { + value: true + }); }); \ No newline at end of file diff --git a/dist/amd/children.js b/dist/amd/children.js index 0a541c09..0e3341af 100644 --- a/dist/amd/children.js +++ b/dist/amd/children.js @@ -1,135 +1,145 @@ define(["exports"], function (exports) { - "use strict"; - - var _prototypeProperties = function (child, staticProps, instanceProps) { if (staticProps) Object.defineProperties(child, staticProps); if (instanceProps) Object.defineProperties(child.prototype, instanceProps); }; - - var noMutations = []; - - var ChildObserver = exports.ChildObserver = (function () { - function ChildObserver(property, changeHandler, selector) { - this.selector = selector; - this.changeHandler = changeHandler; - this.property = property; - } - - _prototypeProperties(ChildObserver, null, { - createBinding: { - value: function createBinding(target, behavior) { - return new ChildObserverBinder(this.selector, target, this.property, behavior, this.changeHandler); - }, - writable: true, - configurable: true - } - }); - - return ChildObserver; - })(); - var ChildObserverBinder = exports.ChildObserverBinder = (function () { - function ChildObserverBinder(selector, target, property, behavior, changeHandler) { - this.selector = selector; - this.target = target; - this.property = property; - this.target = target; - this.behavior = behavior; - this.changeHandler = changeHandler; - this.observer = new MutationObserver(this.onChange.bind(this)); - } - - _prototypeProperties(ChildObserverBinder, null, { - bind: { - value: function bind(source) { - var items, - results, - i, - ii, - node, - behavior = this.behavior; - - this.observer.observe(this.target, { childList: true, subtree: true }); - - items = behavior[this.property]; - if (!items) { - items = behavior[this.property] = []; - } else { - items.length = 0; - } - - results = this.target.querySelectorAll(this.selector); - - for (i = 0, ii = results.length; i < ii; ++i) { - node = results[i]; - items.push(node.primaryBehavior ? node.primaryBehavior.executionContext : node); - } - - if (this.changeHandler) { - this.behavior[this.changeHandler](noMutations); - } - }, - writable: true, - configurable: true - }, - unbind: { - value: function unbind() { - this.observer.disconnect(); - }, - writable: true, - configurable: true - }, - onChange: { - value: function onChange(mutations) { - var items = this.behavior[this.property], - selector = this.selector; - - mutations.forEach(function (record) { - var added = record.addedNodes, - removed = record.removedNodes, - prev = record.previousSibling, - i, - ii, - primary, - index, - node; - - for (i = 0, ii = removed.length; i < ii; ++i) { - node = removed[i]; - if (node.nodeType === 1 && node.matches(selector)) { - primary = node.primaryBehavior ? node.primaryBehavior.executionContext : node; - index = items.indexOf(primary); - if (index != -1) { - items.splice(index, 1); - } - } - } - - for (i = 0, ii = added.length; i < ii; ++i) { - node = added[i]; - if (node.nodeType === 1 && node.matches(selector)) { - primary = node.primaryBehavior ? node.primaryBehavior.executionContext : node; - index = 0; - - while (prev) { - if (prev.nodeType === 1 && prev.matches(selector)) { - index++; - } - - prev = prev.previousSibling; - } - - items.splice(index, 0, primary); - } - } - }); - - if (this.changeHandler) { - this.behavior[this.changeHandler](mutations); - } - }, - writable: true, - configurable: true - } - }); - - return ChildObserverBinder; - })(); - exports.__esModule = true; + "use strict"; + + var _prototypeProperties = function (child, staticProps, instanceProps) { if (staticProps) Object.defineProperties(child, staticProps); if (instanceProps) Object.defineProperties(child.prototype, instanceProps); }; + + var _classCallCheck = function (instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }; + + var noMutations = []; + + var ChildObserver = exports.ChildObserver = (function () { + function ChildObserver(property, changeHandler, selector) { + _classCallCheck(this, ChildObserver); + + this.selector = selector; + this.changeHandler = changeHandler; + this.property = property; + } + + _prototypeProperties(ChildObserver, null, { + createBinding: { + value: function createBinding(target, behavior) { + return new ChildObserverBinder(this.selector, target, this.property, behavior, this.changeHandler); + }, + writable: true, + configurable: true + } + }); + + return ChildObserver; + })(); + + var ChildObserverBinder = exports.ChildObserverBinder = (function () { + function ChildObserverBinder(selector, target, property, behavior, changeHandler) { + _classCallCheck(this, ChildObserverBinder); + + this.selector = selector; + this.target = target; + this.property = property; + this.target = target; + this.behavior = behavior; + this.changeHandler = changeHandler; + this.observer = new MutationObserver(this.onChange.bind(this)); + } + + _prototypeProperties(ChildObserverBinder, null, { + bind: { + value: function bind(source) { + var items, + results, + i, + ii, + node, + behavior = this.behavior; + + this.observer.observe(this.target, { childList: true, subtree: true }); + + items = behavior[this.property]; + if (!items) { + items = behavior[this.property] = []; + } else { + items.length = 0; + } + + results = this.target.querySelectorAll(this.selector); + + for (i = 0, ii = results.length; i < ii; ++i) { + node = results[i]; + items.push(node.primaryBehavior ? node.primaryBehavior.executionContext : node); + } + + if (this.changeHandler) { + this.behavior[this.changeHandler](noMutations); + } + }, + writable: true, + configurable: true + }, + unbind: { + value: function unbind() { + this.observer.disconnect(); + }, + writable: true, + configurable: true + }, + onChange: { + value: function onChange(mutations) { + var items = this.behavior[this.property], + selector = this.selector; + + mutations.forEach(function (record) { + var added = record.addedNodes, + removed = record.removedNodes, + prev = record.previousSibling, + i, + ii, + primary, + index, + node; + + for (i = 0, ii = removed.length; i < ii; ++i) { + node = removed[i]; + if (node.nodeType === 1 && node.matches(selector)) { + primary = node.primaryBehavior ? node.primaryBehavior.executionContext : node; + index = items.indexOf(primary); + if (index != -1) { + items.splice(index, 1); + } + } + } + + for (i = 0, ii = added.length; i < ii; ++i) { + node = added[i]; + if (node.nodeType === 1 && node.matches(selector)) { + primary = node.primaryBehavior ? node.primaryBehavior.executionContext : node; + index = 0; + + while (prev) { + if (prev.nodeType === 1 && prev.matches(selector)) { + index++; + } + + prev = prev.previousSibling; + } + + items.splice(index, 0, primary); + } + } + }); + + if (this.changeHandler) { + this.behavior[this.changeHandler](mutations); + } + }, + writable: true, + configurable: true + } + }); + + return ChildObserverBinder; + })(); + + Object.defineProperty(exports, "__esModule", { + value: true + }); }); \ No newline at end of file diff --git a/dist/amd/composition-engine.js b/dist/amd/composition-engine.js index 03089ff0..5ee7a532 100644 --- a/dist/amd/composition-engine.js +++ b/dist/amd/composition-engine.js @@ -3,6 +3,8 @@ define(["exports", "aurelia-metadata", "aurelia-dependency-injection", "./view-s var _prototypeProperties = function (child, staticProps, instanceProps) { if (staticProps) Object.defineProperties(child, staticProps); if (instanceProps) Object.defineProperties(child.prototype, instanceProps); }; + var _classCallCheck = function (instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }; + var Origin = _aureliaMetadata.Origin; var Metadata = _aureliaMetadata.Metadata; var ViewStrategy = _viewStrategy.ViewStrategy; @@ -10,8 +12,11 @@ define(["exports", "aurelia-metadata", "aurelia-dependency-injection", "./view-s var ResourceCoordinator = _resourceCoordinator.ResourceCoordinator; var ViewEngine = _viewEngine.ViewEngine; var CustomElement = _customElement.CustomElement; + var CompositionEngine = exports.CompositionEngine = (function () { function CompositionEngine(resourceCoordinator, viewEngine) { + _classCallCheck(this, CompositionEngine); + this.resourceCoordinator = resourceCoordinator; this.viewEngine = viewEngine; } @@ -110,6 +115,7 @@ define(["exports", "aurelia-metadata", "aurelia-dependency-injection", "./view-s compose: { value: function compose(instruction) { var _this = this; + instruction.childContainer = instruction.childContainer || instruction.container.createChild(); instruction.view = ViewStrategy.normalize(instruction.view); @@ -143,5 +149,8 @@ define(["exports", "aurelia-metadata", "aurelia-dependency-injection", "./view-s return CompositionEngine; })(); - exports.__esModule = true; + + Object.defineProperty(exports, "__esModule", { + value: true + }); }); \ No newline at end of file diff --git a/dist/amd/content-selector.js b/dist/amd/content-selector.js index 897f9e70..38494d81 100644 --- a/dist/amd/content-selector.js +++ b/dist/amd/content-selector.js @@ -1,146 +1,153 @@ define(["exports"], function (exports) { - "use strict"; - - var _prototypeProperties = function (child, staticProps, instanceProps) { if (staticProps) Object.defineProperties(child, staticProps); if (instanceProps) Object.defineProperties(child.prototype, instanceProps); }; - - if (Element && !Element.prototype.matches) { - var proto = Element.prototype; - proto.matches = proto.matchesSelector || proto.mozMatchesSelector || proto.msMatchesSelector || proto.oMatchesSelector || proto.webkitMatchesSelector; - } - - var placeholder = []; - - function findInsertionPoint(groups, index) { - var insertionPoint; - - while (!insertionPoint && index >= 0) { - insertionPoint = groups[index][0]; - index--; - } - - return insertionPoint || anchor; - } - - var ContentSelector = exports.ContentSelector = (function () { - function ContentSelector(anchor, selector) { - this.anchor = anchor; - this.selector = selector; - this.all = !this.selector; - this.groups = []; - } - - _prototypeProperties(ContentSelector, { - applySelectors: { - value: function applySelectors(view, contentSelectors, callback) { - var currentChild = view.fragment.firstChild, - contentMap = new Map(), - nextSibling, - i, - ii, - contentSelector; - - while (currentChild) { - nextSibling = currentChild.nextSibling; - - if (currentChild.viewSlot) { - var viewSlotSelectors = contentSelectors.map(function (x) { - return x.copyForViewSlot(); - }); - currentChild.viewSlot.installContentSelectors(viewSlotSelectors); - } else { - for (i = 0, ii = contentSelectors.length; i < ii; i++) { - contentSelector = contentSelectors[i]; - if (contentSelector.matches(currentChild)) { - var elements = contentMap.get(contentSelector); - if (!elements) { - elements = []; - contentMap.set(contentSelector, elements); - } - - elements.push(currentChild); - break; - } - } - } - - currentChild = nextSibling; - } - - for (i = 0, ii = contentSelectors.length; i < ii; ++i) { - contentSelector = contentSelectors[i]; - callback(contentSelector, contentMap.get(contentSelector) || placeholder); - } - }, - writable: true, - configurable: true - } - }, { - copyForViewSlot: { - value: function copyForViewSlot() { - return new ContentSelector(this.anchor, this.selector); - }, - writable: true, - configurable: true - }, - matches: { - value: function matches(node) { - return this.all || node.nodeType === 1 && node.matches(this.selector); - }, - writable: true, - configurable: true - }, - add: { - value: function add(group) { - var anchor = this.anchor, - parent = anchor.parentNode, - i, - ii; - - for (i = 0, ii = group.length; i < ii; ++i) { - parent.insertBefore(group[i], anchor); - } - - this.groups.push(group); - }, - writable: true, - configurable: true - }, - insert: { - value: function insert(index, group) { - if (group.length) { - var anchor = findInsertionPoint(this.groups, index) || this.anchor, - parent = anchor.parentNode, - i, - ii; - - for (i = 0, ii = group.length; i < ii; ++i) { - parent.insertBefore(group[i], anchor); - } - } - - this.groups.splice(index, 0, group); - }, - writable: true, - configurable: true - }, - removeAt: { - value: function removeAt(index, fragment) { - var group = this.groups[index], - i, - ii; - - for (i = 0, ii = group.length; i < ii; ++i) { - fragment.appendChild(group[i]); - } - - this.groups.splice(index, 1); - }, - writable: true, - configurable: true - } - }); - - return ContentSelector; - })(); - exports.__esModule = true; + "use strict"; + + var _prototypeProperties = function (child, staticProps, instanceProps) { if (staticProps) Object.defineProperties(child, staticProps); if (instanceProps) Object.defineProperties(child.prototype, instanceProps); }; + + var _classCallCheck = function (instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }; + + if (Element && !Element.prototype.matches) { + var proto = Element.prototype; + proto.matches = proto.matchesSelector || proto.mozMatchesSelector || proto.msMatchesSelector || proto.oMatchesSelector || proto.webkitMatchesSelector; + } + + var placeholder = []; + + function findInsertionPoint(groups, index) { + var insertionPoint; + + while (!insertionPoint && index >= 0) { + insertionPoint = groups[index][0]; + index--; + } + + return insertionPoint || anchor; + } + + var ContentSelector = exports.ContentSelector = (function () { + function ContentSelector(anchor, selector) { + _classCallCheck(this, ContentSelector); + + this.anchor = anchor; + this.selector = selector; + this.all = !this.selector; + this.groups = []; + } + + _prototypeProperties(ContentSelector, { + applySelectors: { + value: function applySelectors(view, contentSelectors, callback) { + var currentChild = view.fragment.firstChild, + contentMap = new Map(), + nextSibling, + i, + ii, + contentSelector; + + while (currentChild) { + nextSibling = currentChild.nextSibling; + + if (currentChild.viewSlot) { + var viewSlotSelectors = contentSelectors.map(function (x) { + return x.copyForViewSlot(); + }); + currentChild.viewSlot.installContentSelectors(viewSlotSelectors); + } else { + for (i = 0, ii = contentSelectors.length; i < ii; i++) { + contentSelector = contentSelectors[i]; + if (contentSelector.matches(currentChild)) { + var elements = contentMap.get(contentSelector); + if (!elements) { + elements = []; + contentMap.set(contentSelector, elements); + } + + elements.push(currentChild); + break; + } + } + } + + currentChild = nextSibling; + } + + for (i = 0, ii = contentSelectors.length; i < ii; ++i) { + contentSelector = contentSelectors[i]; + callback(contentSelector, contentMap.get(contentSelector) || placeholder); + } + }, + writable: true, + configurable: true + } + }, { + copyForViewSlot: { + value: function copyForViewSlot() { + return new ContentSelector(this.anchor, this.selector); + }, + writable: true, + configurable: true + }, + matches: { + value: function matches(node) { + return this.all || node.nodeType === 1 && node.matches(this.selector); + }, + writable: true, + configurable: true + }, + add: { + value: function add(group) { + var anchor = this.anchor, + parent = anchor.parentNode, + i, + ii; + + for (i = 0, ii = group.length; i < ii; ++i) { + parent.insertBefore(group[i], anchor); + } + + this.groups.push(group); + }, + writable: true, + configurable: true + }, + insert: { + value: function insert(index, group) { + if (group.length) { + var anchor = findInsertionPoint(this.groups, index) || this.anchor, + parent = anchor.parentNode, + i, + ii; + + for (i = 0, ii = group.length; i < ii; ++i) { + parent.insertBefore(group[i], anchor); + } + } + + this.groups.splice(index, 0, group); + }, + writable: true, + configurable: true + }, + removeAt: { + value: function removeAt(index, fragment) { + var group = this.groups[index], + i, + ii; + + for (i = 0, ii = group.length; i < ii; ++i) { + fragment.appendChild(group[i]); + } + + this.groups.splice(index, 1); + }, + writable: true, + configurable: true + } + }); + + return ContentSelector; + })(); + + Object.defineProperty(exports, "__esModule", { + value: true + }); }); \ No newline at end of file diff --git a/dist/amd/custom-element.js b/dist/amd/custom-element.js index 96131a99..27e42adc 100644 --- a/dist/amd/custom-element.js +++ b/dist/amd/custom-element.js @@ -5,6 +5,8 @@ define(["exports", "aurelia-metadata", "./behavior-instance", "./behaviors", "./ var _inherits = function (subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) subClass.__proto__ = superClass; }; + var _classCallCheck = function (instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }; + var Metadata = _aureliaMetadata.Metadata; var Origin = _aureliaMetadata.Origin; var ResourceType = _aureliaMetadata.ResourceType; @@ -15,18 +17,23 @@ define(["exports", "aurelia-metadata", "./behavior-instance", "./behaviors", "./ var ViewStrategy = _viewStrategy.ViewStrategy; var hyphenate = _util.hyphenate; - var defaultInstruction = { suppressBind: false }, contentSelectorFactoryOptions = { suppressBind: true }, hasShadowDOM = !!HTMLElement.prototype.createShadowRoot, valuePropertyName = "value"; - var UseShadowDOM = exports.UseShadowDOM = function UseShadowDOM() {}; + var UseShadowDOM = exports.UseShadowDOM = function UseShadowDOM() { + _classCallCheck(this, UseShadowDOM); + }; - var SkipContentProcessing = exports.SkipContentProcessing = function SkipContentProcessing() {}; + var SkipContentProcessing = exports.SkipContentProcessing = function SkipContentProcessing() { + _classCallCheck(this, SkipContentProcessing); + }; var CustomElement = exports.CustomElement = (function (ResourceType) { function CustomElement(tagName) { + _classCallCheck(this, CustomElement); + this.name = tagName; this.properties = []; this.attributes = {}; @@ -61,6 +68,7 @@ define(["exports", "aurelia-metadata", "./behavior-instance", "./behaviors", "./ load: { value: function load(container, target, viewStrategy) { var _this = this; + var options; viewStrategy = viewStrategy || ViewStrategy.getDefault(target); @@ -115,6 +123,7 @@ define(["exports", "aurelia-metadata", "./behavior-instance", "./behaviors", "./ value: function create(container) { var instruction = arguments[1] === undefined ? defaultInstruction : arguments[1]; var element = arguments[2] === undefined ? null : arguments[2]; + var executionContext = instruction.executionContext || container.get(this.target), behaviorInstance = new BehaviorInstance(this, executionContext, instruction), host; @@ -166,5 +175,8 @@ define(["exports", "aurelia-metadata", "./behavior-instance", "./behaviors", "./ return CustomElement; })(ResourceType); - exports.__esModule = true; + + Object.defineProperty(exports, "__esModule", { + value: true + }); }); \ No newline at end of file diff --git a/dist/amd/element-config.js b/dist/amd/element-config.js index fcdc861c..aeb2a926 100644 --- a/dist/amd/element-config.js +++ b/dist/amd/element-config.js @@ -5,12 +5,17 @@ define(["exports", "aurelia-metadata", "aurelia-binding"], function (exports, _a var _inherits = function (subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) subClass.__proto__ = superClass; }; + var _classCallCheck = function (instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }; + var ResourceType = _aureliaMetadata.ResourceType; var EventManager = _aureliaBinding.EventManager; + var ElementConfig = exports.ElementConfig = (function (ResourceType) { function ElementConfig() { - if (Object.getPrototypeOf(ElementConfig) !== null) { - Object.getPrototypeOf(ElementConfig).apply(this, arguments); + _classCallCheck(this, ElementConfig); + + if (ResourceType != null) { + ResourceType.apply(this, arguments); } } @@ -36,5 +41,8 @@ define(["exports", "aurelia-metadata", "aurelia-binding"], function (exports, _a return ElementConfig; })(ResourceType); - exports.__esModule = true; + + Object.defineProperty(exports, "__esModule", { + value: true + }); }); \ No newline at end of file diff --git a/dist/amd/index.js b/dist/amd/index.js index 93c9c01f..7df6c4a8 100644 --- a/dist/amd/index.js +++ b/dist/amd/index.js @@ -1,4 +1,4 @@ -define(["exports", "aurelia-metadata", "./property", "./attached-behavior", "./children", "./custom-element", "./element-config", "./template-controller", "./view-strategy", "./resource-coordinator", "./resource-registry", "./view-compiler", "./view-engine", "./view-factory", "./view-slot", "./binding-language", "./composition-engine"], function (exports, _aureliaMetadata, _property, _attachedBehavior, _children, _customElement, _elementConfig, _templateController, _viewStrategy, _resourceCoordinator, _resourceRegistry, _viewCompiler, _viewEngine, _viewFactory, _viewSlot, _bindingLanguage, _compositionEngine) { +define(["exports", "aurelia-metadata", "./property", "./attached-behavior", "./children", "./custom-element", "./element-config", "./template-controller", "./view-strategy", "./resource-coordinator", "./resource-registry", "./view-compiler", "./view-engine", "./view-factory", "./view-slot", "./binding-language", "./composition-engine", "./animator"], function (exports, _aureliaMetadata, _property, _attachedBehavior, _children, _customElement, _elementConfig, _templateController, _viewStrategy, _resourceCoordinator, _resourceRegistry, _viewCompiler, _viewEngine, _viewFactory, _viewSlot, _bindingLanguage, _compositionEngine, _animator) { "use strict"; var Metadata = _aureliaMetadata.Metadata; @@ -36,7 +36,9 @@ define(["exports", "aurelia-metadata", "./property", "./attached-behavior", "./c exports.ViewSlot = _viewSlot.ViewSlot; exports.BindingLanguage = _bindingLanguage.BindingLanguage; exports.CompositionEngine = _compositionEngine.CompositionEngine; + exports.Animator = _animator.Animator; var Behavior = exports.Behavior = Metadata; + var Behaviour = exports.Behaviour = Metadata; Metadata.configure.classHelper("withProperty", BehaviorProperty); Metadata.configure.classHelper("withOptions", OptionsProperty); @@ -49,5 +51,7 @@ define(["exports", "aurelia-metadata", "./property", "./attached-behavior", "./c Metadata.configure.classHelper("useView", UseView); Metadata.configure.classHelper("noView", NoView); Metadata.configure.classHelper("skipContentProcessing", SkipContentProcessing); - exports.__esModule = true; + Object.defineProperty(exports, "__esModule", { + value: true + }); }); \ No newline at end of file diff --git a/dist/amd/property.js b/dist/amd/property.js index 8173e60e..a8acb0ff 100644 --- a/dist/amd/property.js +++ b/dist/amd/property.js @@ -5,12 +5,17 @@ define(["exports", "./util", "aurelia-binding"], function (exports, _util, _aure var _prototypeProperties = function (child, staticProps, instanceProps) { if (staticProps) Object.defineProperties(child, staticProps); if (instanceProps) Object.defineProperties(child.prototype, instanceProps); }; + var _classCallCheck = function (instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }; + var hyphenate = _util.hyphenate; var ONE_WAY = _aureliaBinding.ONE_WAY; var TWO_WAY = _aureliaBinding.TWO_WAY; var ONE_TIME = _aureliaBinding.ONE_TIME; + var BehaviorProperty = exports.BehaviorProperty = (function () { function BehaviorProperty(name, changeHandler, attribute, defaultValue, defaultBindingMode) { + _classCallCheck(this, BehaviorProperty); + this.name = name; this.changeHandler = changeHandler; this.attribute = attribute || hyphenate(name); @@ -63,10 +68,10 @@ define(["exports", "./util", "aurelia-binding"], function (exports, _util, _aure Object.defineProperty(behavior.target.prototype, this.name, { configurable: true, enumerable: true, - get: function () { + get: function get() { return this.__observers__[that.name].getValue(); }, - set: function (value) { + set: function set(value) { this.__observers__[that.name].setValue(value); } }); @@ -77,6 +82,7 @@ define(["exports", "./util", "aurelia-binding"], function (exports, _util, _aure createObserver: { value: function createObserver(executionContext) { var _this = this; + var selfSubscriber = null; if (this.changeHandler) { @@ -126,12 +132,15 @@ define(["exports", "./util", "aurelia-binding"], function (exports, _util, _aure return BehaviorProperty; })(); + var OptionsProperty = exports.OptionsProperty = (function (BehaviorProperty) { function OptionsProperty(attribute) { for (var _len = arguments.length, rest = Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) { rest[_key - 1] = arguments[_key]; } + _classCallCheck(this, OptionsProperty); + if (typeof attribute === "string") { this.attribute = attribute; } else if (attribute) { @@ -243,8 +252,11 @@ define(["exports", "./util", "aurelia-binding"], function (exports, _util, _aure return OptionsProperty; })(BehaviorProperty); + var BehaviorPropertyObserver = (function () { function BehaviorPropertyObserver(taskQueue, obj, propertyName, selfSubscriber) { + _classCallCheck(this, BehaviorPropertyObserver); + this.taskQueue = taskQueue; this.obj = obj; this.propertyName = propertyName; @@ -319,5 +331,7 @@ define(["exports", "./util", "aurelia-binding"], function (exports, _util, _aure return BehaviorPropertyObserver; })(); - exports.__esModule = true; + Object.defineProperty(exports, "__esModule", { + value: true + }); }); \ No newline at end of file diff --git a/dist/amd/resource-coordinator.js b/dist/amd/resource-coordinator.js index 6de3057d..2e083da6 100644 --- a/dist/amd/resource-coordinator.js +++ b/dist/amd/resource-coordinator.js @@ -3,6 +3,8 @@ define(["exports", "aurelia-loader", "aurelia-path", "aurelia-dependency-injecti var _prototypeProperties = function (child, staticProps, instanceProps) { if (staticProps) Object.defineProperties(child, staticProps); if (instanceProps) Object.defineProperties(child.prototype, instanceProps); }; + var _classCallCheck = function (instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }; + var Loader = _aureliaLoader.Loader; var relativeToFile = _aureliaPath.relativeToFile; var join = _aureliaPath.join; @@ -17,7 +19,6 @@ define(["exports", "aurelia-loader", "aurelia-path", "aurelia-dependency-injecti var ViewEngine = _viewEngine.ViewEngine; var ResourceRegistry = _resourceRegistry.ResourceRegistry; - var id = 0; function nextId() { @@ -26,6 +27,8 @@ define(["exports", "aurelia-loader", "aurelia-path", "aurelia-dependency-injecti var ResourceCoordinator = exports.ResourceCoordinator = (function () { function ResourceCoordinator(loader, container, viewEngine, appResources) { + _classCallCheck(this, ResourceCoordinator); + this.loader = loader; this.container = container; this.viewEngine = viewEngine; @@ -61,6 +64,7 @@ define(["exports", "aurelia-loader", "aurelia-path", "aurelia-dependency-injecti loadElement: { value: function loadElement(moduleImport, moduleMember, viewStategy) { var _this = this; + return this._loadAndAnalyzeModuleForElement(moduleImport, moduleMember, this.importedModules, false).then(function (info) { var type = info.type; @@ -79,6 +83,7 @@ define(["exports", "aurelia-loader", "aurelia-path", "aurelia-dependency-injecti _loadAndAnalyzeModuleForElement: { value: function _loadAndAnalyzeModuleForElement(moduleImport, moduleMember, cache, skipCacheLookup) { var _this = this; + var existing = !skipCacheLookup && cache[moduleImport]; if (existing) { @@ -174,6 +179,7 @@ define(["exports", "aurelia-loader", "aurelia-path", "aurelia-dependency-injecti importResourcesFromModuleIds: { value: function importResourcesFromModuleIds(importIds) { var _this = this; + return this.loader.loadAllModules(importIds).then(function (imports) { return _this.importResourcesFromModules(imports, importIds); }); @@ -260,8 +266,11 @@ define(["exports", "aurelia-loader", "aurelia-path", "aurelia-dependency-injecti return ResourceCoordinator; })(); + var ResourceModule = (function () { function ResourceModule(source, element, resources) { + _classCallCheck(this, ResourceModule); + var i, ii, org; this.source = source; @@ -396,5 +405,7 @@ define(["exports", "aurelia-loader", "aurelia-path", "aurelia-dependency-injecti type: Metadata.on(viewModelType).first(CustomElement) || new CustomElement() } : null, resources); } - exports.__esModule = true; + Object.defineProperty(exports, "__esModule", { + value: true + }); }); \ No newline at end of file diff --git a/dist/amd/resource-registry.js b/dist/amd/resource-registry.js index 38cb68cb..bf534e53 100644 --- a/dist/amd/resource-registry.js +++ b/dist/amd/resource-registry.js @@ -7,8 +7,9 @@ define(["exports", "aurelia-path"], function (exports, _aureliaPath) { var _prototypeProperties = function (child, staticProps, instanceProps) { if (staticProps) Object.defineProperties(child, staticProps); if (instanceProps) Object.defineProperties(child.prototype, instanceProps); }; - var relativeToFile = _aureliaPath.relativeToFile; + var _classCallCheck = function (instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }; + var relativeToFile = _aureliaPath.relativeToFile; function register(lookup, name, resource, type) { if (!name) { @@ -29,6 +30,8 @@ define(["exports", "aurelia-path"], function (exports, _aureliaPath) { var ResourceRegistry = exports.ResourceRegistry = (function () { function ResourceRegistry() { + _classCallCheck(this, ResourceRegistry); + this.attributes = {}; this.elements = {}; this.valueConverters = {}; @@ -84,8 +87,11 @@ define(["exports", "aurelia-path"], function (exports, _aureliaPath) { return ResourceRegistry; })(); + var ViewResources = exports.ViewResources = (function (ResourceRegistry) { function ViewResources(parent, viewUrl) { + _classCallCheck(this, ViewResources); + _get(Object.getPrototypeOf(ViewResources.prototype), "constructor", this).call(this); this.parent = parent; this.viewUrl = viewUrl; @@ -134,5 +140,8 @@ define(["exports", "aurelia-path"], function (exports, _aureliaPath) { return ViewResources; })(ResourceRegistry); - exports.__esModule = true; + + Object.defineProperty(exports, "__esModule", { + value: true + }); }); \ No newline at end of file diff --git a/dist/amd/template-controller.js b/dist/amd/template-controller.js index 1d215fe4..885013ae 100644 --- a/dist/amd/template-controller.js +++ b/dist/amd/template-controller.js @@ -5,12 +5,17 @@ define(["exports", "aurelia-metadata", "./behavior-instance", "./behaviors", "./ var _inherits = function (subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) subClass.__proto__ = superClass; }; + var _classCallCheck = function (instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }; + var ResourceType = _aureliaMetadata.ResourceType; var BehaviorInstance = _behaviorInstance.BehaviorInstance; var configureBehavior = _behaviors.configureBehavior; var hyphenate = _util.hyphenate; + var TemplateController = exports.TemplateController = (function (ResourceType) { function TemplateController(attribute) { + _classCallCheck(this, TemplateController); + this.name = attribute; this.properties = []; this.attributes = {}; @@ -62,8 +67,10 @@ define(["exports", "aurelia-metadata", "./behavior-instance", "./behaviors", "./ if (node.parentNode) { node.parentNode.replaceChild(template, node); } else if (window.ShadowDOMPolyfill) { + //HACK: IE template element and shadow dom polyfills not quite right... ShadowDOMPolyfill.unwrap(parentNode).replaceChild(ShadowDOMPolyfill.unwrap(template), ShadowDOMPolyfill.unwrap(node)); } else { + //HACK: same as above parentNode.replaceChild(template, node); } @@ -100,5 +107,8 @@ define(["exports", "aurelia-metadata", "./behavior-instance", "./behaviors", "./ return TemplateController; })(ResourceType); - exports.__esModule = true; + + Object.defineProperty(exports, "__esModule", { + value: true + }); }); \ No newline at end of file diff --git a/dist/amd/util.js b/dist/amd/util.js index 42ffee82..c210a28a 100644 --- a/dist/amd/util.js +++ b/dist/amd/util.js @@ -11,5 +11,8 @@ define(["exports"], function (exports) { function hyphenate(name) { return (name.charAt(0).toLowerCase() + name.slice(1)).replace(capitalMatcher, addHyphenAndLower); } - exports.__esModule = true; + + Object.defineProperty(exports, "__esModule", { + value: true + }); }); \ No newline at end of file diff --git a/dist/amd/view-compiler.js b/dist/amd/view-compiler.js index 5daa6525..45098784 100644 --- a/dist/amd/view-compiler.js +++ b/dist/amd/view-compiler.js @@ -3,11 +3,12 @@ define(["exports", "./resource-registry", "./view-factory", "./binding-language" var _prototypeProperties = function (child, staticProps, instanceProps) { if (staticProps) Object.defineProperties(child, staticProps); if (instanceProps) Object.defineProperties(child.prototype, instanceProps); }; + var _classCallCheck = function (instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }; + var ResourceRegistry = _resourceRegistry.ResourceRegistry; var ViewFactory = _viewFactory.ViewFactory; var BindingLanguage = _bindingLanguage.BindingLanguage; - var nextInjectorId = 0, defaultCompileOptions = { targetShadowDOM: false }, hasShadowDOM = !!HTMLElement.prototype.createShadowRoot; @@ -52,6 +53,8 @@ define(["exports", "./resource-registry", "./view-factory", "./binding-language" var ViewCompiler = exports.ViewCompiler = (function () { function ViewCompiler(bindingLanguage) { + _classCallCheck(this, ViewCompiler); + this.bindingLanguage = bindingLanguage; } @@ -67,6 +70,7 @@ define(["exports", "./resource-registry", "./view-factory", "./binding-language" compile: { value: function compile(templateOrFragment, resources) { var options = arguments[2] === undefined ? defaultCompileOptions : arguments[2]; + var instructions = [], targetShadowDOM = options.targetShadowDOM, content; @@ -97,18 +101,21 @@ define(["exports", "./resource-registry", "./view-factory", "./binding-language" value: function compileNode(node, resources, instructions, parentNode, parentInjectorId, targetLightDOM) { switch (node.nodeType) { case 1: + //element node return this.compileElement(node, resources, instructions, parentNode, parentInjectorId, targetLightDOM); case 3: + //text node var expression = this.bindingLanguage.parseText(resources, node.textContent); if (expression) { var marker = document.createElement("au-marker"); marker.className = "au-target"; - node.parentNode.insertBefore(marker, node); + (node.parentNode || parentNode).insertBefore(marker, node); node.textContent = " "; instructions.push({ contentExpression: expression }); } return node.nextSibling; case 11: + //document fragment node var currentChild = node.firstChild; while (currentChild) { currentChild = this.compileNode(currentChild, resources, instructions, node, parentInjectorId, targetLightDOM); @@ -174,25 +181,31 @@ define(["exports", "./resource-registry", "./view-factory", "./binding-language" elementProperty = null; if (type) { - knownAttribute = resources.mapAttribute(info.attrName); + //do we have an attached behavior? + knownAttribute = resources.mapAttribute(info.attrName); //map the local name to real name if (knownAttribute) { property = type.attributes[knownAttribute]; if (property) { - info.defaultBindingMode = property.defaultBindingMode; + //if there's a defined property + info.defaultBindingMode = property.defaultBindingMode; //set the default binding mode if (!info.command && !info.expression) { - info.command = property.hasOptions ? "options" : null; + // if there is no command or detected expression + info.command = property.hasOptions ? "options" : null; //and it is an optons property, set the options command } } } } else if (elementInstruction) { + //or if this is on a custom element elementProperty = elementInstruction.type.attributes[info.attrName]; if (elementProperty) { - info.defaultBindingMode = elementProperty.defaultBindingMode; + //and this attribute is a custom property + info.defaultBindingMode = elementProperty.defaultBindingMode; //set the default binding mode if (!info.command && !info.expression) { - info.command = elementProperty.hasOptions ? "options" : null; + // if there is no command or detected expression + info.command = elementProperty.hasOptions ? "options" : null; //and it is an optons property, set the options command } } } @@ -204,45 +217,60 @@ define(["exports", "./resource-registry", "./view-factory", "./binding-language" } if (instruction) { + //HAS BINDINGS if (instruction.alteredAttr) { type = resources.getAttribute(instruction.attrName); } if (instruction.discrete) { + //ref binding or listener binding expressions.push(instruction); } else { + //attribute bindings if (type) { + //templator or attached behavior found instruction.type = type; configureProperties(instruction, resources); if (type.liftsContent) { + //template controller instruction.originalAttrName = attrName; liftingInstruction = instruction; break; } else { + //attached behavior behaviorInstructions.push(instruction); } } else if (elementProperty) { + //custom element attribute elementInstruction.attributes[info.attrName].targetProperty = elementProperty.name; } else { + //standard attribute binding expressions.push(instruction.attributes[instruction.attrName]); } } } else { + //NO BINDINGS if (type) { + //templator or attached behavior found instruction = { attrName: attrName, type: type, attributes: {} }; instruction.attributes[resources.mapAttribute(attrName)] = attrValue; if (type.liftsContent) { + //template controller instruction.originalAttrName = attrName; liftingInstruction = instruction; break; } else { + //attached behavior behaviorInstructions.push(instruction); } } else if (elementProperty) { + //custom element attribute elementInstruction.attributes[attrName] = attrValue; } + + //else; normal attribute; do nothing } } @@ -298,5 +326,8 @@ define(["exports", "./resource-registry", "./view-factory", "./binding-language" return ViewCompiler; })(); - exports.__esModule = true; + + Object.defineProperty(exports, "__esModule", { + value: true + }); }); \ No newline at end of file diff --git a/dist/amd/view-engine.js b/dist/amd/view-engine.js index 0ef0e4d4..e7159077 100644 --- a/dist/amd/view-engine.js +++ b/dist/amd/view-engine.js @@ -3,6 +3,8 @@ define(["exports", "aurelia-logging", "aurelia-loader", "aurelia-path", "./view- var _prototypeProperties = function (child, staticProps, instanceProps) { if (staticProps) Object.defineProperties(child, staticProps); if (instanceProps) Object.defineProperties(child.prototype, instanceProps); }; + var _classCallCheck = function (instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }; + var LogManager = _aureliaLogging; var Loader = _aureliaLoader.Loader; var relativeToFile = _aureliaPath.relativeToFile; @@ -10,12 +12,13 @@ define(["exports", "aurelia-logging", "aurelia-loader", "aurelia-path", "./view- var ResourceRegistry = _resourceRegistry.ResourceRegistry; var ViewResources = _resourceRegistry.ViewResources; - var importSplitter = /\s*,\s*/, logger = LogManager.getLogger("templating"); var ViewEngine = exports.ViewEngine = (function () { function ViewEngine(loader, viewCompiler, appResources) { + _classCallCheck(this, ViewEngine); + this.loader = loader; this.viewCompiler = viewCompiler; this.appResources = appResources; @@ -34,6 +37,7 @@ define(["exports", "aurelia-logging", "aurelia-loader", "aurelia-path", "./view- loadViewFactory: { value: function loadViewFactory(url, compileOptions, associatedModuleId) { var _this = this; + var existing = this.importedViews[url]; if (existing) { return Promise.resolve(existing); @@ -58,6 +62,7 @@ define(["exports", "aurelia-logging", "aurelia-loader", "aurelia-path", "./view- loadTemplateResources: { value: function loadTemplateResources(templateUrl, template, associatedModuleId) { var _this = this; + var importIds, names, i, @@ -119,5 +124,8 @@ define(["exports", "aurelia-logging", "aurelia-loader", "aurelia-path", "./view- return ViewEngine; })(); - exports.__esModule = true; + + Object.defineProperty(exports, "__esModule", { + value: true + }); }); \ No newline at end of file diff --git a/dist/amd/view-factory.js b/dist/amd/view-factory.js index fa6137a7..3570e917 100644 --- a/dist/amd/view-factory.js +++ b/dist/amd/view-factory.js @@ -3,13 +3,14 @@ define(["exports", "aurelia-dependency-injection", "./view", "./view-slot", "./c var _prototypeProperties = function (child, staticProps, instanceProps) { if (staticProps) Object.defineProperties(child, staticProps); if (instanceProps) Object.defineProperties(child.prototype, instanceProps); }; + var _classCallCheck = function (instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }; + var Container = _aureliaDependencyInjection.Container; var View = _view.View; var ViewSlot = _viewSlot.ViewSlot; var ContentSelector = _contentSelector.ContentSelector; var ViewResources = _resourceRegistry.ViewResources; - function elementContainerGet(key) { if (key === Element) { return this.element; @@ -101,6 +102,8 @@ define(["exports", "aurelia-dependency-injection", "./view", "./view-slot", "./c var BoundViewFactory = exports.BoundViewFactory = (function () { function BoundViewFactory(parentContainer, viewFactory, executionContext) { + _classCallCheck(this, BoundViewFactory); + this.parentContainer = parentContainer; this.viewFactory = viewFactory; this.executionContext = executionContext; @@ -125,7 +128,6 @@ define(["exports", "aurelia-dependency-injection", "./view", "./view-slot", "./c return BoundViewFactory; })(); - var defaultFactoryOptions = { systemControlled: false, suppressBind: false @@ -133,6 +135,8 @@ define(["exports", "aurelia-dependency-injection", "./view", "./view-slot", "./c var ViewFactory = exports.ViewFactory = (function () { function ViewFactory(template, instructions, resources) { + _classCallCheck(this, ViewFactory); + this.template = template; this.instructions = instructions; this.resources = resources; @@ -142,6 +146,7 @@ define(["exports", "aurelia-dependency-injection", "./view", "./view-slot", "./c create: { value: function create(container, executionContext) { var options = arguments[2] === undefined ? defaultFactoryOptions : arguments[2]; + var fragment = this.template.cloneNode(true), instructables = fragment.querySelectorAll(".au-target"), instructions = this.instructions, @@ -175,5 +180,8 @@ define(["exports", "aurelia-dependency-injection", "./view", "./view-slot", "./c return ViewFactory; })(); - exports.__esModule = true; + + Object.defineProperty(exports, "__esModule", { + value: true + }); }); \ No newline at end of file diff --git a/dist/amd/view-slot.js b/dist/amd/view-slot.js index 99f881df..919a94f3 100644 --- a/dist/amd/view-slot.js +++ b/dist/amd/view-slot.js @@ -1,18 +1,26 @@ -define(["exports", "./content-selector"], function (exports, _contentSelector) { +define(["exports", "./content-selector", "./animator"], function (exports, _contentSelector, _animator) { "use strict"; var _prototypeProperties = function (child, staticProps, instanceProps) { if (staticProps) Object.defineProperties(child, staticProps); if (instanceProps) Object.defineProperties(child.prototype, instanceProps); }; + var _classCallCheck = function (instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }; + var ContentSelector = _contentSelector.ContentSelector; + var Animator = _animator.Animator; + var ViewSlot = exports.ViewSlot = (function () { function ViewSlot(anchor, anchorIsContainer, executionContext) { + var animator = arguments[3] === undefined ? Animator.instance : arguments[3]; + + _classCallCheck(this, ViewSlot); + this.anchor = anchor; this.viewAddMethod = anchorIsContainer ? "appendNodesTo" : "insertNodesBefore"; this.executionContext = executionContext; + this.animator = animator; this.children = []; this.isBound = false; this.isAttached = false; - anchor.viewSlot = this; } @@ -22,6 +30,9 @@ define(["exports", "./content-selector"], function (exports, _contentSelector) { var parent = this.anchor; this.children.push({ + fragment: parent, + firstChild: parent.firstChild, + lastChild: parent.lastChild, removeNodes: function removeNodes() { var last; @@ -83,6 +94,11 @@ define(["exports", "./content-selector"], function (exports, _contentSelector) { if (this.isAttached) { view.attached(); + // Animate page itself + var element = view.firstChild.nextElementSibling; + if (view.firstChild.nodeType === 8 && element !== undefined && element.nodeType === 1 && element.classList.contains("au-animate")) { + this.animator.enter(element); + } } }, writable: true, @@ -107,6 +123,7 @@ define(["exports", "./content-selector"], function (exports, _contentSelector) { remove: { value: function remove(view) { view.removeNodes(); + this.children.splice(this.children.indexOf(view), 1); if (this.isAttached) { @@ -118,45 +135,87 @@ define(["exports", "./content-selector"], function (exports, _contentSelector) { }, removeAt: { value: function removeAt(index) { + var _this = this; + var view = this.children[index]; - view.removeNodes(); - this.children.splice(index, 1); + var removeAction = function () { + view.removeNodes(); + _this.children.splice(index, 1); - if (this.isAttached) { - view.detached(); - } + if (_this.isAttached) { + view.detached(); + } - return view; + return view; + }; + + var element = view.firstChild.nextElementSibling; + if (view.firstChild.nodeType === 8 && element !== undefined && element.nodeType === 1 && element.classList.contains("au-animate")) { + return this.animator.leave(element).then(function () { + return removeAction(); + }); + } else { + return removeAction(); + } }, writable: true, configurable: true }, removeAll: { value: function removeAll() { + var _this = this; + var children = this.children, ii = children.length, i; - for (i = 0; i < ii; ++i) { - children[i].removeNodes(); - } + var rmPromises = []; - if (this.isAttached) { - for (i = 0; i < ii; ++i) { - children[i].detached(); + children.forEach(function (child) { + var element = child.firstChild.nextElementSibling; + if (child.firstChild !== undefined && child.firstChild.nodeType === 8 && element !== undefined && element.nodeType === 1 && element.classList.contains("au-animate")) { + rmPromises.push(_this.animator.leave(element).then(function () { + child.removeNodes(); + })); + } else { + child.removeNodes(); } - } + }); - this.children = []; + var removeAction = function () { + if (_this.isAttached) { + for (i = 0; i < ii; ++i) { + children[i].detached(); + } + } + + _this.children = []; + }; + + if (rmPromises.length > 0) { + return Promise.all(rmPromises).then(function () { + removeAction(); + }); + } else { + removeAction(); + } }, writable: true, configurable: true }, swap: { value: function swap(view) { - this.removeAll(); - this.add(view); + var _this = this; + + var removeResponse = this.removeAll(); + if (removeResponse !== undefined) { + removeResponse.then(function () { + _this.add(view); + }); + } else { + this.add(view); + } }, writable: true, configurable: true @@ -174,6 +233,11 @@ define(["exports", "./content-selector"], function (exports, _contentSelector) { children = this.children; for (i = 0, ii = children.length; i < ii; ++i) { children[i].attached(); + + var element = children[i].firstChild.nextElementSibling; + if (children[i].firstChild.nodeType === 8 && element !== undefined && element.nodeType === 1 && element.classList.contains("au-animate")) { + this.animator.enter(element); + } } }, writable: true, @@ -315,5 +379,8 @@ define(["exports", "./content-selector"], function (exports, _contentSelector) { return ViewSlot; })(); - exports.__esModule = true; + + Object.defineProperty(exports, "__esModule", { + value: true + }); }); \ No newline at end of file diff --git a/dist/amd/view-strategy.js b/dist/amd/view-strategy.js index 60b54f7d..26eb7266 100644 --- a/dist/amd/view-strategy.js +++ b/dist/amd/view-strategy.js @@ -5,11 +5,16 @@ define(["exports", "aurelia-metadata", "aurelia-path"], function (exports, _aure var _prototypeProperties = function (child, staticProps, instanceProps) { if (staticProps) Object.defineProperties(child, staticProps); if (instanceProps) Object.defineProperties(child.prototype, instanceProps); }; + var _classCallCheck = function (instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }; + var Metadata = _aureliaMetadata.Metadata; var Origin = _aureliaMetadata.Origin; var relativeToFile = _aureliaPath.relativeToFile; + var ViewStrategy = exports.ViewStrategy = (function () { - function ViewStrategy() {} + function ViewStrategy() { + _classCallCheck(this, ViewStrategy); + } _prototypeProperties(ViewStrategy, { normalize: { @@ -70,8 +75,11 @@ define(["exports", "aurelia-metadata", "aurelia-path"], function (exports, _aure return ViewStrategy; })(); + var UseView = exports.UseView = (function (ViewStrategy) { function UseView(path) { + _classCallCheck(this, UseView); + this.path = path; } @@ -100,8 +108,11 @@ define(["exports", "aurelia-metadata", "aurelia-path"], function (exports, _aure return UseView; })(ViewStrategy); + var ConventionalView = exports.ConventionalView = (function (ViewStrategy) { function ConventionalView(moduleId) { + _classCallCheck(this, ConventionalView); + this.moduleId = moduleId; this.viewUrl = ConventionalView.convertModuleIdToViewUrl(moduleId); } @@ -128,10 +139,13 @@ define(["exports", "aurelia-metadata", "aurelia-path"], function (exports, _aure return ConventionalView; })(ViewStrategy); + var NoView = exports.NoView = (function (ViewStrategy) { function NoView() { - if (Object.getPrototypeOf(NoView) !== null) { - Object.getPrototypeOf(NoView).apply(this, arguments); + _classCallCheck(this, NoView); + + if (ViewStrategy != null) { + ViewStrategy.apply(this, arguments); } } @@ -149,5 +163,8 @@ define(["exports", "aurelia-metadata", "aurelia-path"], function (exports, _aure return NoView; })(ViewStrategy); - exports.__esModule = true; + + Object.defineProperty(exports, "__esModule", { + value: true + }); }); \ No newline at end of file diff --git a/dist/amd/view.js b/dist/amd/view.js index fc80f483..912f10a1 100644 --- a/dist/amd/view.js +++ b/dist/amd/view.js @@ -3,8 +3,15 @@ define(["exports"], function (exports) { var _prototypeProperties = function (child, staticProps, instanceProps) { if (staticProps) Object.defineProperties(child, staticProps); if (instanceProps) Object.defineProperties(child.prototype, instanceProps); }; + var _classCallCheck = function (instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }; + + //NOTE: Adding a fragment to the document causes the nodes to be removed from the fragment. + //NOTE: Adding to the fragment, causes the nodes to be removed from the document. + var View = exports.View = (function () { function View(fragment, behaviors, bindings, children, systemControlled, contentSelectors) { + _classCallCheck(this, View); + this.fragment = fragment; this.behaviors = behaviors; this.bindings = bindings; @@ -209,5 +216,8 @@ define(["exports"], function (exports) { return View; })(); - exports.__esModule = true; + + Object.defineProperty(exports, "__esModule", { + value: true + }); }); \ No newline at end of file diff --git a/dist/commonjs/animator.js b/dist/commonjs/animator.js new file mode 100644 index 00000000..10b13a59 --- /dev/null +++ b/dist/commonjs/animator.js @@ -0,0 +1,90 @@ +"use strict"; + +var _prototypeProperties = function (child, staticProps, instanceProps) { if (staticProps) Object.defineProperties(child, staticProps); if (instanceProps) Object.defineProperties(child.prototype, instanceProps); }; + +var _classCallCheck = function (instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }; + +var Animator = exports.Animator = (function () { + function Animator() { + _classCallCheck(this, Animator); + + Animator.instance = this; + this.animationStack = []; + } + + _prototypeProperties(Animator, null, { + addMultipleEventListener: { + value: function addMultipleEventListener(el, s, fn) { + var evts = s.split(" "), + i, + ii; + + for (i = 0, ii = evts.length; i < ii; ++i) { + el.addEventListener(evts[i], fn, false); + } + }, + writable: true, + configurable: true + }, + addAnimationToStack: { + value: function addAnimationToStack(animId) { + if (this.animationStack.indexOf(animId) < 0) { + this.animationStack.push(animId); + } + }, + writable: true, + configurable: true + }, + removeAnimationFromStack: { + value: function removeAnimationFromStack(animId) { + var idx = this.animationStack.indexOf(animId); + if (idx > -1) { + this.animationStack.splice(idx, 1); + } + }, + writable: true, + configurable: true + }, + move: { + value: function move() { + return Promise.resolve(false); + }, + writable: true, + configurable: true + }, + enter: { + value: function enter(element) { + return Promise.resolve(false); + }, + writable: true, + configurable: true + }, + leave: { + value: function leave(element) { + return Promise.resolve(false); + }, + writable: true, + configurable: true + }, + removeClass: { + value: function removeClass(element, className) { + return Promise.resolve(false); + }, + writable: true, + configurable: true + }, + addClass: { + value: function addClass(element, className) { + return Promise.resolve(false); + }, + writable: true, + configurable: true + } + }); + + return Animator; +})(); + +Object.defineProperty(exports, "__esModule", { + value: true +}); \ No newline at end of file diff --git a/dist/commonjs/attached-behavior.js b/dist/commonjs/attached-behavior.js index 1f7ff97a..ace6f69e 100644 --- a/dist/commonjs/attached-behavior.js +++ b/dist/commonjs/attached-behavior.js @@ -4,12 +4,20 @@ var _prototypeProperties = function (child, staticProps, instanceProps) { if (st var _inherits = function (subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) subClass.__proto__ = superClass; }; +var _classCallCheck = function (instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }; + var ResourceType = require("aurelia-metadata").ResourceType; + var BehaviorInstance = require("./behavior-instance").BehaviorInstance; + var configureBehavior = require("./behaviors").configureBehavior; + var hyphenate = require("./util").hyphenate; + var AttachedBehavior = exports.AttachedBehavior = (function (ResourceType) { function AttachedBehavior(attribute) { + _classCallCheck(this, AttachedBehavior); + this.name = attribute; this.properties = []; this.attributes = {}; @@ -79,4 +87,7 @@ var AttachedBehavior = exports.AttachedBehavior = (function (ResourceType) { return AttachedBehavior; })(ResourceType); -exports.__esModule = true; \ No newline at end of file + +Object.defineProperty(exports, "__esModule", { + value: true +}); \ No newline at end of file diff --git a/dist/commonjs/behavior-instance.js b/dist/commonjs/behavior-instance.js index 2b23c357..02775682 100644 --- a/dist/commonjs/behavior-instance.js +++ b/dist/commonjs/behavior-instance.js @@ -2,8 +2,12 @@ var _prototypeProperties = function (child, staticProps, instanceProps) { if (staticProps) Object.defineProperties(child, staticProps); if (instanceProps) Object.defineProperties(child.prototype, instanceProps); }; +var _classCallCheck = function (instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }; + var BehaviorInstance = exports.BehaviorInstance = (function () { function BehaviorInstance(behavior, executionContext, instruction) { + _classCallCheck(this, BehaviorInstance); + this.behavior = behavior; this.executionContext = executionContext; @@ -111,4 +115,7 @@ var BehaviorInstance = exports.BehaviorInstance = (function () { return BehaviorInstance; })(); -exports.__esModule = true; \ No newline at end of file + +Object.defineProperty(exports, "__esModule", { + value: true +}); \ No newline at end of file diff --git a/dist/commonjs/behaviors.js b/dist/commonjs/behaviors.js index 48a746cb..ae65893f 100644 --- a/dist/commonjs/behaviors.js +++ b/dist/commonjs/behaviors.js @@ -1,12 +1,19 @@ "use strict"; exports.configureBehavior = configureBehavior; + var Metadata = require("aurelia-metadata").Metadata; + var TaskQueue = require("aurelia-task-queue").TaskQueue; + var ObserverLocator = require("aurelia-binding").ObserverLocator; + var ChildObserver = require("./children").ChildObserver; + var BehaviorProperty = require("./property").BehaviorProperty; + var hyphenate = require("./util").hyphenate; + function configureBehavior(container, behavior, target, valuePropertyName) { var proto = target.prototype, taskQueue = container.get(TaskQueue), @@ -62,4 +69,7 @@ function configureBehavior(container, behavior, target, valuePropertyName) { behavior.childExpression = meta.first(ChildObserver); } -exports.__esModule = true; \ No newline at end of file + +Object.defineProperty(exports, "__esModule", { + value: true +}); \ No newline at end of file diff --git a/dist/commonjs/binding-language.js b/dist/commonjs/binding-language.js index 75d12e85..85544610 100644 --- a/dist/commonjs/binding-language.js +++ b/dist/commonjs/binding-language.js @@ -2,8 +2,12 @@ var _prototypeProperties = function (child, staticProps, instanceProps) { if (staticProps) Object.defineProperties(child, staticProps); if (instanceProps) Object.defineProperties(child.prototype, instanceProps); }; +var _classCallCheck = function (instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }; + var BindingLanguage = exports.BindingLanguage = (function () { - function BindingLanguage() {} + function BindingLanguage() { + _classCallCheck(this, BindingLanguage); + } _prototypeProperties(BindingLanguage, null, { inspectAttribute: { @@ -31,4 +35,7 @@ var BindingLanguage = exports.BindingLanguage = (function () { return BindingLanguage; })(); -exports.__esModule = true; \ No newline at end of file + +Object.defineProperty(exports, "__esModule", { + value: true +}); \ No newline at end of file diff --git a/dist/commonjs/children.js b/dist/commonjs/children.js index 80229786..832db081 100644 --- a/dist/commonjs/children.js +++ b/dist/commonjs/children.js @@ -2,132 +2,142 @@ var _prototypeProperties = function (child, staticProps, instanceProps) { if (staticProps) Object.defineProperties(child, staticProps); if (instanceProps) Object.defineProperties(child.prototype, instanceProps); }; +var _classCallCheck = function (instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }; + var noMutations = []; var ChildObserver = exports.ChildObserver = (function () { - function ChildObserver(property, changeHandler, selector) { - this.selector = selector; - this.changeHandler = changeHandler; - this.property = property; - } - - _prototypeProperties(ChildObserver, null, { - createBinding: { - value: function createBinding(target, behavior) { - return new ChildObserverBinder(this.selector, target, this.property, behavior, this.changeHandler); - }, - writable: true, - configurable: true - } - }); - - return ChildObserver; + function ChildObserver(property, changeHandler, selector) { + _classCallCheck(this, ChildObserver); + + this.selector = selector; + this.changeHandler = changeHandler; + this.property = property; + } + + _prototypeProperties(ChildObserver, null, { + createBinding: { + value: function createBinding(target, behavior) { + return new ChildObserverBinder(this.selector, target, this.property, behavior, this.changeHandler); + }, + writable: true, + configurable: true + } + }); + + return ChildObserver; })(); + var ChildObserverBinder = exports.ChildObserverBinder = (function () { - function ChildObserverBinder(selector, target, property, behavior, changeHandler) { - this.selector = selector; - this.target = target; - this.property = property; - this.target = target; - this.behavior = behavior; - this.changeHandler = changeHandler; - this.observer = new MutationObserver(this.onChange.bind(this)); - } - - _prototypeProperties(ChildObserverBinder, null, { - bind: { - value: function bind(source) { - var items, - results, - i, - ii, - node, - behavior = this.behavior; - - this.observer.observe(this.target, { childList: true, subtree: true }); - - items = behavior[this.property]; - if (!items) { - items = behavior[this.property] = []; - } else { - items.length = 0; - } - - results = this.target.querySelectorAll(this.selector); - - for (i = 0, ii = results.length; i < ii; ++i) { - node = results[i]; - items.push(node.primaryBehavior ? node.primaryBehavior.executionContext : node); - } - - if (this.changeHandler) { - this.behavior[this.changeHandler](noMutations); - } - }, - writable: true, - configurable: true - }, - unbind: { - value: function unbind() { - this.observer.disconnect(); - }, - writable: true, - configurable: true - }, - onChange: { - value: function onChange(mutations) { - var items = this.behavior[this.property], - selector = this.selector; - - mutations.forEach(function (record) { - var added = record.addedNodes, - removed = record.removedNodes, - prev = record.previousSibling, - i, - ii, - primary, - index, - node; - - for (i = 0, ii = removed.length; i < ii; ++i) { - node = removed[i]; - if (node.nodeType === 1 && node.matches(selector)) { - primary = node.primaryBehavior ? node.primaryBehavior.executionContext : node; - index = items.indexOf(primary); - if (index != -1) { - items.splice(index, 1); - } - } - } - - for (i = 0, ii = added.length; i < ii; ++i) { - node = added[i]; - if (node.nodeType === 1 && node.matches(selector)) { - primary = node.primaryBehavior ? node.primaryBehavior.executionContext : node; - index = 0; - - while (prev) { - if (prev.nodeType === 1 && prev.matches(selector)) { - index++; - } - - prev = prev.previousSibling; - } - - items.splice(index, 0, primary); - } - } - }); - - if (this.changeHandler) { - this.behavior[this.changeHandler](mutations); - } - }, - writable: true, - configurable: true - } - }); - - return ChildObserverBinder; + function ChildObserverBinder(selector, target, property, behavior, changeHandler) { + _classCallCheck(this, ChildObserverBinder); + + this.selector = selector; + this.target = target; + this.property = property; + this.target = target; + this.behavior = behavior; + this.changeHandler = changeHandler; + this.observer = new MutationObserver(this.onChange.bind(this)); + } + + _prototypeProperties(ChildObserverBinder, null, { + bind: { + value: function bind(source) { + var items, + results, + i, + ii, + node, + behavior = this.behavior; + + this.observer.observe(this.target, { childList: true, subtree: true }); + + items = behavior[this.property]; + if (!items) { + items = behavior[this.property] = []; + } else { + items.length = 0; + } + + results = this.target.querySelectorAll(this.selector); + + for (i = 0, ii = results.length; i < ii; ++i) { + node = results[i]; + items.push(node.primaryBehavior ? node.primaryBehavior.executionContext : node); + } + + if (this.changeHandler) { + this.behavior[this.changeHandler](noMutations); + } + }, + writable: true, + configurable: true + }, + unbind: { + value: function unbind() { + this.observer.disconnect(); + }, + writable: true, + configurable: true + }, + onChange: { + value: function onChange(mutations) { + var items = this.behavior[this.property], + selector = this.selector; + + mutations.forEach(function (record) { + var added = record.addedNodes, + removed = record.removedNodes, + prev = record.previousSibling, + i, + ii, + primary, + index, + node; + + for (i = 0, ii = removed.length; i < ii; ++i) { + node = removed[i]; + if (node.nodeType === 1 && node.matches(selector)) { + primary = node.primaryBehavior ? node.primaryBehavior.executionContext : node; + index = items.indexOf(primary); + if (index != -1) { + items.splice(index, 1); + } + } + } + + for (i = 0, ii = added.length; i < ii; ++i) { + node = added[i]; + if (node.nodeType === 1 && node.matches(selector)) { + primary = node.primaryBehavior ? node.primaryBehavior.executionContext : node; + index = 0; + + while (prev) { + if (prev.nodeType === 1 && prev.matches(selector)) { + index++; + } + + prev = prev.previousSibling; + } + + items.splice(index, 0, primary); + } + } + }); + + if (this.changeHandler) { + this.behavior[this.changeHandler](mutations); + } + }, + writable: true, + configurable: true + } + }); + + return ChildObserverBinder; })(); -exports.__esModule = true; \ No newline at end of file + +Object.defineProperty(exports, "__esModule", { + value: true +}); \ No newline at end of file diff --git a/dist/commonjs/composition-engine.js b/dist/commonjs/composition-engine.js index dfe0d372..4f568613 100644 --- a/dist/commonjs/composition-engine.js +++ b/dist/commonjs/composition-engine.js @@ -2,21 +2,30 @@ var _prototypeProperties = function (child, staticProps, instanceProps) { if (staticProps) Object.defineProperties(child, staticProps); if (instanceProps) Object.defineProperties(child.prototype, instanceProps); }; +var _classCallCheck = function (instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }; + var _aureliaMetadata = require("aurelia-metadata"); var Origin = _aureliaMetadata.Origin; var Metadata = _aureliaMetadata.Metadata; + require("aurelia-dependency-injection"); var _viewStrategy = require("./view-strategy"); var ViewStrategy = _viewStrategy.ViewStrategy; var UseView = _viewStrategy.UseView; + var ResourceCoordinator = require("./resource-coordinator").ResourceCoordinator; + var ViewEngine = require("./view-engine").ViewEngine; + var CustomElement = require("./custom-element").CustomElement; + var CompositionEngine = exports.CompositionEngine = (function () { function CompositionEngine(resourceCoordinator, viewEngine) { + _classCallCheck(this, CompositionEngine); + this.resourceCoordinator = resourceCoordinator; this.viewEngine = viewEngine; } @@ -115,6 +124,7 @@ var CompositionEngine = exports.CompositionEngine = (function () { compose: { value: function compose(instruction) { var _this = this; + instruction.childContainer = instruction.childContainer || instruction.container.createChild(); instruction.view = ViewStrategy.normalize(instruction.view); @@ -148,4 +158,7 @@ var CompositionEngine = exports.CompositionEngine = (function () { return CompositionEngine; })(); -exports.__esModule = true; \ No newline at end of file + +Object.defineProperty(exports, "__esModule", { + value: true +}); \ No newline at end of file diff --git a/dist/commonjs/content-selector.js b/dist/commonjs/content-selector.js index e5f1828d..c49c6b27 100644 --- a/dist/commonjs/content-selector.js +++ b/dist/commonjs/content-selector.js @@ -2,143 +2,150 @@ var _prototypeProperties = function (child, staticProps, instanceProps) { if (staticProps) Object.defineProperties(child, staticProps); if (instanceProps) Object.defineProperties(child.prototype, instanceProps); }; +var _classCallCheck = function (instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }; + if (Element && !Element.prototype.matches) { - var proto = Element.prototype; - proto.matches = proto.matchesSelector || proto.mozMatchesSelector || proto.msMatchesSelector || proto.oMatchesSelector || proto.webkitMatchesSelector; + var proto = Element.prototype; + proto.matches = proto.matchesSelector || proto.mozMatchesSelector || proto.msMatchesSelector || proto.oMatchesSelector || proto.webkitMatchesSelector; } var placeholder = []; function findInsertionPoint(groups, index) { - var insertionPoint; + var insertionPoint; - while (!insertionPoint && index >= 0) { - insertionPoint = groups[index][0]; - index--; - } + while (!insertionPoint && index >= 0) { + insertionPoint = groups[index][0]; + index--; + } - return insertionPoint || anchor; + return insertionPoint || anchor; } var ContentSelector = exports.ContentSelector = (function () { - function ContentSelector(anchor, selector) { - this.anchor = anchor; - this.selector = selector; - this.all = !this.selector; - this.groups = []; - } - - _prototypeProperties(ContentSelector, { - applySelectors: { - value: function applySelectors(view, contentSelectors, callback) { - var currentChild = view.fragment.firstChild, - contentMap = new Map(), - nextSibling, - i, - ii, - contentSelector; - - while (currentChild) { - nextSibling = currentChild.nextSibling; - - if (currentChild.viewSlot) { - var viewSlotSelectors = contentSelectors.map(function (x) { - return x.copyForViewSlot(); - }); - currentChild.viewSlot.installContentSelectors(viewSlotSelectors); - } else { - for (i = 0, ii = contentSelectors.length; i < ii; i++) { - contentSelector = contentSelectors[i]; - if (contentSelector.matches(currentChild)) { - var elements = contentMap.get(contentSelector); - if (!elements) { - elements = []; - contentMap.set(contentSelector, elements); - } - - elements.push(currentChild); - break; - } - } - } - - currentChild = nextSibling; - } - - for (i = 0, ii = contentSelectors.length; i < ii; ++i) { - contentSelector = contentSelectors[i]; - callback(contentSelector, contentMap.get(contentSelector) || placeholder); - } - }, - writable: true, - configurable: true - } - }, { - copyForViewSlot: { - value: function copyForViewSlot() { - return new ContentSelector(this.anchor, this.selector); - }, - writable: true, - configurable: true - }, - matches: { - value: function matches(node) { - return this.all || node.nodeType === 1 && node.matches(this.selector); - }, - writable: true, - configurable: true - }, - add: { - value: function add(group) { - var anchor = this.anchor, - parent = anchor.parentNode, - i, - ii; - - for (i = 0, ii = group.length; i < ii; ++i) { - parent.insertBefore(group[i], anchor); - } - - this.groups.push(group); - }, - writable: true, - configurable: true - }, - insert: { - value: function insert(index, group) { - if (group.length) { - var anchor = findInsertionPoint(this.groups, index) || this.anchor, - parent = anchor.parentNode, - i, - ii; - - for (i = 0, ii = group.length; i < ii; ++i) { - parent.insertBefore(group[i], anchor); - } - } - - this.groups.splice(index, 0, group); - }, - writable: true, - configurable: true - }, - removeAt: { - value: function removeAt(index, fragment) { - var group = this.groups[index], - i, - ii; - - for (i = 0, ii = group.length; i < ii; ++i) { - fragment.appendChild(group[i]); - } - - this.groups.splice(index, 1); - }, - writable: true, - configurable: true - } - }); - - return ContentSelector; + function ContentSelector(anchor, selector) { + _classCallCheck(this, ContentSelector); + + this.anchor = anchor; + this.selector = selector; + this.all = !this.selector; + this.groups = []; + } + + _prototypeProperties(ContentSelector, { + applySelectors: { + value: function applySelectors(view, contentSelectors, callback) { + var currentChild = view.fragment.firstChild, + contentMap = new Map(), + nextSibling, + i, + ii, + contentSelector; + + while (currentChild) { + nextSibling = currentChild.nextSibling; + + if (currentChild.viewSlot) { + var viewSlotSelectors = contentSelectors.map(function (x) { + return x.copyForViewSlot(); + }); + currentChild.viewSlot.installContentSelectors(viewSlotSelectors); + } else { + for (i = 0, ii = contentSelectors.length; i < ii; i++) { + contentSelector = contentSelectors[i]; + if (contentSelector.matches(currentChild)) { + var elements = contentMap.get(contentSelector); + if (!elements) { + elements = []; + contentMap.set(contentSelector, elements); + } + + elements.push(currentChild); + break; + } + } + } + + currentChild = nextSibling; + } + + for (i = 0, ii = contentSelectors.length; i < ii; ++i) { + contentSelector = contentSelectors[i]; + callback(contentSelector, contentMap.get(contentSelector) || placeholder); + } + }, + writable: true, + configurable: true + } + }, { + copyForViewSlot: { + value: function copyForViewSlot() { + return new ContentSelector(this.anchor, this.selector); + }, + writable: true, + configurable: true + }, + matches: { + value: function matches(node) { + return this.all || node.nodeType === 1 && node.matches(this.selector); + }, + writable: true, + configurable: true + }, + add: { + value: function add(group) { + var anchor = this.anchor, + parent = anchor.parentNode, + i, + ii; + + for (i = 0, ii = group.length; i < ii; ++i) { + parent.insertBefore(group[i], anchor); + } + + this.groups.push(group); + }, + writable: true, + configurable: true + }, + insert: { + value: function insert(index, group) { + if (group.length) { + var anchor = findInsertionPoint(this.groups, index) || this.anchor, + parent = anchor.parentNode, + i, + ii; + + for (i = 0, ii = group.length; i < ii; ++i) { + parent.insertBefore(group[i], anchor); + } + } + + this.groups.splice(index, 0, group); + }, + writable: true, + configurable: true + }, + removeAt: { + value: function removeAt(index, fragment) { + var group = this.groups[index], + i, + ii; + + for (i = 0, ii = group.length; i < ii; ++i) { + fragment.appendChild(group[i]); + } + + this.groups.splice(index, 1); + }, + writable: true, + configurable: true + } + }); + + return ContentSelector; })(); -exports.__esModule = true; \ No newline at end of file + +Object.defineProperty(exports, "__esModule", { + value: true +}); \ No newline at end of file diff --git a/dist/commonjs/custom-element.js b/dist/commonjs/custom-element.js index badcd455..c5bf85d7 100644 --- a/dist/commonjs/custom-element.js +++ b/dist/commonjs/custom-element.js @@ -4,30 +4,43 @@ var _prototypeProperties = function (child, staticProps, instanceProps) { if (st var _inherits = function (subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) subClass.__proto__ = superClass; }; +var _classCallCheck = function (instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }; + var _aureliaMetadata = require("aurelia-metadata"); var Metadata = _aureliaMetadata.Metadata; var Origin = _aureliaMetadata.Origin; var ResourceType = _aureliaMetadata.ResourceType; + var BehaviorInstance = require("./behavior-instance").BehaviorInstance; + var configureBehavior = require("./behaviors").configureBehavior; + var ContentSelector = require("./content-selector").ContentSelector; + var ViewEngine = require("./view-engine").ViewEngine; + var ViewStrategy = require("./view-strategy").ViewStrategy; -var hyphenate = require("./util").hyphenate; +var hyphenate = require("./util").hyphenate; var defaultInstruction = { suppressBind: false }, contentSelectorFactoryOptions = { suppressBind: true }, hasShadowDOM = !!HTMLElement.prototype.createShadowRoot, valuePropertyName = "value"; -var UseShadowDOM = exports.UseShadowDOM = function UseShadowDOM() {}; +var UseShadowDOM = exports.UseShadowDOM = function UseShadowDOM() { + _classCallCheck(this, UseShadowDOM); +}; -var SkipContentProcessing = exports.SkipContentProcessing = function SkipContentProcessing() {}; +var SkipContentProcessing = exports.SkipContentProcessing = function SkipContentProcessing() { + _classCallCheck(this, SkipContentProcessing); +}; var CustomElement = exports.CustomElement = (function (ResourceType) { function CustomElement(tagName) { + _classCallCheck(this, CustomElement); + this.name = tagName; this.properties = []; this.attributes = {}; @@ -62,6 +75,7 @@ var CustomElement = exports.CustomElement = (function (ResourceType) { load: { value: function load(container, target, viewStrategy) { var _this = this; + var options; viewStrategy = viewStrategy || ViewStrategy.getDefault(target); @@ -116,6 +130,7 @@ var CustomElement = exports.CustomElement = (function (ResourceType) { value: function create(container) { var instruction = arguments[1] === undefined ? defaultInstruction : arguments[1]; var element = arguments[2] === undefined ? null : arguments[2]; + var executionContext = instruction.executionContext || container.get(this.target), behaviorInstance = new BehaviorInstance(this, executionContext, instruction), host; @@ -167,4 +182,7 @@ var CustomElement = exports.CustomElement = (function (ResourceType) { return CustomElement; })(ResourceType); -exports.__esModule = true; \ No newline at end of file + +Object.defineProperty(exports, "__esModule", { + value: true +}); \ No newline at end of file diff --git a/dist/commonjs/element-config.js b/dist/commonjs/element-config.js index f805cb34..74044560 100644 --- a/dist/commonjs/element-config.js +++ b/dist/commonjs/element-config.js @@ -4,12 +4,18 @@ var _prototypeProperties = function (child, staticProps, instanceProps) { if (st var _inherits = function (subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) subClass.__proto__ = superClass; }; +var _classCallCheck = function (instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }; + var ResourceType = require("aurelia-metadata").ResourceType; + var EventManager = require("aurelia-binding").EventManager; + var ElementConfig = exports.ElementConfig = (function (ResourceType) { function ElementConfig() { - if (Object.getPrototypeOf(ElementConfig) !== null) { - Object.getPrototypeOf(ElementConfig).apply(this, arguments); + _classCallCheck(this, ElementConfig); + + if (ResourceType != null) { + ResourceType.apply(this, arguments); } } @@ -35,4 +41,7 @@ var ElementConfig = exports.ElementConfig = (function (ResourceType) { return ElementConfig; })(ResourceType); -exports.__esModule = true; \ No newline at end of file + +Object.defineProperty(exports, "__esModule", { + value: true +}); \ No newline at end of file diff --git a/dist/commonjs/index.js b/dist/commonjs/index.js index 83876e09..4d1951c7 100644 --- a/dist/commonjs/index.js +++ b/dist/commonjs/index.js @@ -1,27 +1,34 @@ "use strict"; var Metadata = require("aurelia-metadata").Metadata; + var _property = require("./property"); var BehaviorProperty = _property.BehaviorProperty; var OptionsProperty = _property.OptionsProperty; + var _attachedBehavior = require("./attached-behavior"); var AttachedBehavior = _attachedBehavior.AttachedBehavior; + var _children = require("./children"); var ChildObserver = _children.ChildObserver; + var _customElement = require("./custom-element"); var CustomElement = _customElement.CustomElement; var UseShadowDOM = _customElement.UseShadowDOM; var SkipContentProcessing = _customElement.SkipContentProcessing; + var _elementConfig = require("./element-config"); var ElementConfig = _elementConfig.ElementConfig; + var _templateController = require("./template-controller"); var TemplateController = _templateController.TemplateController; + var _viewStrategy = require("./view-strategy"); var UseView = _viewStrategy.UseView; @@ -30,6 +37,7 @@ exports.AttachedBehavior = _attachedBehavior.AttachedBehavior; exports.BehaviorProperty = _property.BehaviorProperty; exports.OptionsProperty = _property.OptionsProperty; exports.ResourceCoordinator = require("./resource-coordinator").ResourceCoordinator; + var _resourceRegistry = require("./resource-registry"); exports.ResourceRegistry = _resourceRegistry.ResourceRegistry; @@ -46,6 +54,7 @@ exports.ConventionalView = _viewStrategy.ConventionalView; exports.NoView = _viewStrategy.NoView; exports.ViewCompiler = require("./view-compiler").ViewCompiler; exports.ViewEngine = require("./view-engine").ViewEngine; + var _viewFactory = require("./view-factory"); exports.ViewFactory = _viewFactory.ViewFactory; @@ -53,7 +62,9 @@ exports.BoundViewFactory = _viewFactory.BoundViewFactory; exports.ViewSlot = require("./view-slot").ViewSlot; exports.BindingLanguage = require("./binding-language").BindingLanguage; exports.CompositionEngine = require("./composition-engine").CompositionEngine; +exports.Animator = require("./animator").Animator; var Behavior = exports.Behavior = Metadata; +var Behaviour = exports.Behaviour = Metadata; Metadata.configure.classHelper("withProperty", BehaviorProperty); Metadata.configure.classHelper("withOptions", OptionsProperty); @@ -66,4 +77,6 @@ Metadata.configure.classHelper("templateController", TemplateController); Metadata.configure.classHelper("useView", UseView); Metadata.configure.classHelper("noView", NoView); Metadata.configure.classHelper("skipContentProcessing", SkipContentProcessing); -exports.__esModule = true; \ No newline at end of file +Object.defineProperty(exports, "__esModule", { + value: true +}); \ No newline at end of file diff --git a/dist/commonjs/property.js b/dist/commonjs/property.js index 238936c1..8eccdf1b 100644 --- a/dist/commonjs/property.js +++ b/dist/commonjs/property.js @@ -4,14 +4,20 @@ var _inherits = function (subClass, superClass) { if (typeof superClass !== "fun var _prototypeProperties = function (child, staticProps, instanceProps) { if (staticProps) Object.defineProperties(child, staticProps); if (instanceProps) Object.defineProperties(child.prototype, instanceProps); }; +var _classCallCheck = function (instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }; + var hyphenate = require("./util").hyphenate; + var _aureliaBinding = require("aurelia-binding"); var ONE_WAY = _aureliaBinding.ONE_WAY; var TWO_WAY = _aureliaBinding.TWO_WAY; var ONE_TIME = _aureliaBinding.ONE_TIME; + var BehaviorProperty = exports.BehaviorProperty = (function () { function BehaviorProperty(name, changeHandler, attribute, defaultValue, defaultBindingMode) { + _classCallCheck(this, BehaviorProperty); + this.name = name; this.changeHandler = changeHandler; this.attribute = attribute || hyphenate(name); @@ -64,10 +70,10 @@ var BehaviorProperty = exports.BehaviorProperty = (function () { Object.defineProperty(behavior.target.prototype, this.name, { configurable: true, enumerable: true, - get: function () { + get: function get() { return this.__observers__[that.name].getValue(); }, - set: function (value) { + set: function set(value) { this.__observers__[that.name].setValue(value); } }); @@ -78,6 +84,7 @@ var BehaviorProperty = exports.BehaviorProperty = (function () { createObserver: { value: function createObserver(executionContext) { var _this = this; + var selfSubscriber = null; if (this.changeHandler) { @@ -127,12 +134,15 @@ var BehaviorProperty = exports.BehaviorProperty = (function () { return BehaviorProperty; })(); + var OptionsProperty = exports.OptionsProperty = (function (BehaviorProperty) { function OptionsProperty(attribute) { for (var _len = arguments.length, rest = Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) { rest[_key - 1] = arguments[_key]; } + _classCallCheck(this, OptionsProperty); + if (typeof attribute === "string") { this.attribute = attribute; } else if (attribute) { @@ -244,8 +254,11 @@ var OptionsProperty = exports.OptionsProperty = (function (BehaviorProperty) { return OptionsProperty; })(BehaviorProperty); + var BehaviorPropertyObserver = (function () { function BehaviorPropertyObserver(taskQueue, obj, propertyName, selfSubscriber) { + _classCallCheck(this, BehaviorPropertyObserver); + this.taskQueue = taskQueue; this.obj = obj; this.propertyName = propertyName; @@ -320,4 +333,6 @@ var BehaviorPropertyObserver = (function () { return BehaviorPropertyObserver; })(); -exports.__esModule = true; \ No newline at end of file +Object.defineProperty(exports, "__esModule", { + value: true +}); \ No newline at end of file diff --git a/dist/commonjs/resource-coordinator.js b/dist/commonjs/resource-coordinator.js index 88e64bc2..93ad5c00 100644 --- a/dist/commonjs/resource-coordinator.js +++ b/dist/commonjs/resource-coordinator.js @@ -2,24 +2,34 @@ var _prototypeProperties = function (child, staticProps, instanceProps) { if (staticProps) Object.defineProperties(child, staticProps); if (instanceProps) Object.defineProperties(child.prototype, instanceProps); }; +var _classCallCheck = function (instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }; + var Loader = require("aurelia-loader").Loader; + var _aureliaPath = require("aurelia-path"); var relativeToFile = _aureliaPath.relativeToFile; var join = _aureliaPath.join; + var Container = require("aurelia-dependency-injection").Container; + var _aureliaMetadata = require("aurelia-metadata"); var Metadata = _aureliaMetadata.Metadata; var ResourceType = _aureliaMetadata.ResourceType; var Origin = _aureliaMetadata.Origin; + var ValueConverter = require("aurelia-binding").ValueConverter; + var CustomElement = require("./custom-element").CustomElement; + var AttachedBehavior = require("./attached-behavior").AttachedBehavior; + var TemplateController = require("./template-controller").TemplateController; + var ViewEngine = require("./view-engine").ViewEngine; -var ResourceRegistry = require("./resource-registry").ResourceRegistry; +var ResourceRegistry = require("./resource-registry").ResourceRegistry; var id = 0; @@ -29,6 +39,8 @@ function nextId() { var ResourceCoordinator = exports.ResourceCoordinator = (function () { function ResourceCoordinator(loader, container, viewEngine, appResources) { + _classCallCheck(this, ResourceCoordinator); + this.loader = loader; this.container = container; this.viewEngine = viewEngine; @@ -64,6 +76,7 @@ var ResourceCoordinator = exports.ResourceCoordinator = (function () { loadElement: { value: function loadElement(moduleImport, moduleMember, viewStategy) { var _this = this; + return this._loadAndAnalyzeModuleForElement(moduleImport, moduleMember, this.importedModules, false).then(function (info) { var type = info.type; @@ -82,6 +95,7 @@ var ResourceCoordinator = exports.ResourceCoordinator = (function () { _loadAndAnalyzeModuleForElement: { value: function _loadAndAnalyzeModuleForElement(moduleImport, moduleMember, cache, skipCacheLookup) { var _this = this; + var existing = !skipCacheLookup && cache[moduleImport]; if (existing) { @@ -177,6 +191,7 @@ var ResourceCoordinator = exports.ResourceCoordinator = (function () { importResourcesFromModuleIds: { value: function importResourcesFromModuleIds(importIds) { var _this = this; + return this.loader.loadAllModules(importIds).then(function (imports) { return _this.importResourcesFromModules(imports, importIds); }); @@ -263,8 +278,11 @@ var ResourceCoordinator = exports.ResourceCoordinator = (function () { return ResourceCoordinator; })(); + var ResourceModule = (function () { function ResourceModule(source, element, resources) { + _classCallCheck(this, ResourceModule); + var i, ii, org; this.source = source; @@ -399,4 +417,6 @@ function analyzeModule(moduleInstance, viewModelMember) { type: Metadata.on(viewModelType).first(CustomElement) || new CustomElement() } : null, resources); } -exports.__esModule = true; \ No newline at end of file +Object.defineProperty(exports, "__esModule", { + value: true +}); \ No newline at end of file diff --git a/dist/commonjs/resource-registry.js b/dist/commonjs/resource-registry.js index 1425a174..fc0fdac9 100644 --- a/dist/commonjs/resource-registry.js +++ b/dist/commonjs/resource-registry.js @@ -6,8 +6,9 @@ var _inherits = function (subClass, superClass) { if (typeof superClass !== "fun var _prototypeProperties = function (child, staticProps, instanceProps) { if (staticProps) Object.defineProperties(child, staticProps); if (instanceProps) Object.defineProperties(child.prototype, instanceProps); }; -var relativeToFile = require("aurelia-path").relativeToFile; +var _classCallCheck = function (instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }; +var relativeToFile = require("aurelia-path").relativeToFile; function register(lookup, name, resource, type) { if (!name) { @@ -28,6 +29,8 @@ function register(lookup, name, resource, type) { var ResourceRegistry = exports.ResourceRegistry = (function () { function ResourceRegistry() { + _classCallCheck(this, ResourceRegistry); + this.attributes = {}; this.elements = {}; this.valueConverters = {}; @@ -83,8 +86,11 @@ var ResourceRegistry = exports.ResourceRegistry = (function () { return ResourceRegistry; })(); + var ViewResources = exports.ViewResources = (function (ResourceRegistry) { function ViewResources(parent, viewUrl) { + _classCallCheck(this, ViewResources); + _get(Object.getPrototypeOf(ViewResources.prototype), "constructor", this).call(this); this.parent = parent; this.viewUrl = viewUrl; @@ -133,4 +139,7 @@ var ViewResources = exports.ViewResources = (function (ResourceRegistry) { return ViewResources; })(ResourceRegistry); -exports.__esModule = true; \ No newline at end of file + +Object.defineProperty(exports, "__esModule", { + value: true +}); \ No newline at end of file diff --git a/dist/commonjs/template-controller.js b/dist/commonjs/template-controller.js index fc5825ad..106c940f 100644 --- a/dist/commonjs/template-controller.js +++ b/dist/commonjs/template-controller.js @@ -4,12 +4,20 @@ var _prototypeProperties = function (child, staticProps, instanceProps) { if (st var _inherits = function (subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) subClass.__proto__ = superClass; }; +var _classCallCheck = function (instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }; + var ResourceType = require("aurelia-metadata").ResourceType; + var BehaviorInstance = require("./behavior-instance").BehaviorInstance; + var configureBehavior = require("./behaviors").configureBehavior; + var hyphenate = require("./util").hyphenate; + var TemplateController = exports.TemplateController = (function (ResourceType) { function TemplateController(attribute) { + _classCallCheck(this, TemplateController); + this.name = attribute; this.properties = []; this.attributes = {}; @@ -61,8 +69,10 @@ var TemplateController = exports.TemplateController = (function (ResourceType) { if (node.parentNode) { node.parentNode.replaceChild(template, node); } else if (window.ShadowDOMPolyfill) { + //HACK: IE template element and shadow dom polyfills not quite right... ShadowDOMPolyfill.unwrap(parentNode).replaceChild(ShadowDOMPolyfill.unwrap(template), ShadowDOMPolyfill.unwrap(node)); } else { + //HACK: same as above parentNode.replaceChild(template, node); } @@ -99,4 +109,7 @@ var TemplateController = exports.TemplateController = (function (ResourceType) { return TemplateController; })(ResourceType); -exports.__esModule = true; \ No newline at end of file + +Object.defineProperty(exports, "__esModule", { + value: true +}); \ No newline at end of file diff --git a/dist/commonjs/util.js b/dist/commonjs/util.js index c0a97ff1..fdeafc7a 100644 --- a/dist/commonjs/util.js +++ b/dist/commonjs/util.js @@ -10,4 +10,7 @@ function addHyphenAndLower(char) { function hyphenate(name) { return (name.charAt(0).toLowerCase() + name.slice(1)).replace(capitalMatcher, addHyphenAndLower); } -exports.__esModule = true; \ No newline at end of file + +Object.defineProperty(exports, "__esModule", { + value: true +}); \ No newline at end of file diff --git a/dist/commonjs/view-compiler.js b/dist/commonjs/view-compiler.js index 4d42bcba..2e21a817 100644 --- a/dist/commonjs/view-compiler.js +++ b/dist/commonjs/view-compiler.js @@ -2,10 +2,13 @@ var _prototypeProperties = function (child, staticProps, instanceProps) { if (staticProps) Object.defineProperties(child, staticProps); if (instanceProps) Object.defineProperties(child.prototype, instanceProps); }; +var _classCallCheck = function (instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }; + var ResourceRegistry = require("./resource-registry").ResourceRegistry; + var ViewFactory = require("./view-factory").ViewFactory; -var BindingLanguage = require("./binding-language").BindingLanguage; +var BindingLanguage = require("./binding-language").BindingLanguage; var nextInjectorId = 0, defaultCompileOptions = { targetShadowDOM: false }, @@ -51,6 +54,8 @@ function makeIntoInstructionTarget(element) { var ViewCompiler = exports.ViewCompiler = (function () { function ViewCompiler(bindingLanguage) { + _classCallCheck(this, ViewCompiler); + this.bindingLanguage = bindingLanguage; } @@ -66,6 +71,7 @@ var ViewCompiler = exports.ViewCompiler = (function () { compile: { value: function compile(templateOrFragment, resources) { var options = arguments[2] === undefined ? defaultCompileOptions : arguments[2]; + var instructions = [], targetShadowDOM = options.targetShadowDOM, content; @@ -96,18 +102,21 @@ var ViewCompiler = exports.ViewCompiler = (function () { value: function compileNode(node, resources, instructions, parentNode, parentInjectorId, targetLightDOM) { switch (node.nodeType) { case 1: + //element node return this.compileElement(node, resources, instructions, parentNode, parentInjectorId, targetLightDOM); case 3: + //text node var expression = this.bindingLanguage.parseText(resources, node.textContent); if (expression) { var marker = document.createElement("au-marker"); marker.className = "au-target"; - node.parentNode.insertBefore(marker, node); + (node.parentNode || parentNode).insertBefore(marker, node); node.textContent = " "; instructions.push({ contentExpression: expression }); } return node.nextSibling; case 11: + //document fragment node var currentChild = node.firstChild; while (currentChild) { currentChild = this.compileNode(currentChild, resources, instructions, node, parentInjectorId, targetLightDOM); @@ -173,25 +182,31 @@ var ViewCompiler = exports.ViewCompiler = (function () { elementProperty = null; if (type) { - knownAttribute = resources.mapAttribute(info.attrName); + //do we have an attached behavior? + knownAttribute = resources.mapAttribute(info.attrName); //map the local name to real name if (knownAttribute) { property = type.attributes[knownAttribute]; if (property) { - info.defaultBindingMode = property.defaultBindingMode; + //if there's a defined property + info.defaultBindingMode = property.defaultBindingMode; //set the default binding mode if (!info.command && !info.expression) { - info.command = property.hasOptions ? "options" : null; + // if there is no command or detected expression + info.command = property.hasOptions ? "options" : null; //and it is an optons property, set the options command } } } } else if (elementInstruction) { + //or if this is on a custom element elementProperty = elementInstruction.type.attributes[info.attrName]; if (elementProperty) { - info.defaultBindingMode = elementProperty.defaultBindingMode; + //and this attribute is a custom property + info.defaultBindingMode = elementProperty.defaultBindingMode; //set the default binding mode if (!info.command && !info.expression) { - info.command = elementProperty.hasOptions ? "options" : null; + // if there is no command or detected expression + info.command = elementProperty.hasOptions ? "options" : null; //and it is an optons property, set the options command } } } @@ -203,45 +218,60 @@ var ViewCompiler = exports.ViewCompiler = (function () { } if (instruction) { + //HAS BINDINGS if (instruction.alteredAttr) { type = resources.getAttribute(instruction.attrName); } if (instruction.discrete) { + //ref binding or listener binding expressions.push(instruction); } else { + //attribute bindings if (type) { + //templator or attached behavior found instruction.type = type; configureProperties(instruction, resources); if (type.liftsContent) { + //template controller instruction.originalAttrName = attrName; liftingInstruction = instruction; break; } else { + //attached behavior behaviorInstructions.push(instruction); } } else if (elementProperty) { + //custom element attribute elementInstruction.attributes[info.attrName].targetProperty = elementProperty.name; } else { + //standard attribute binding expressions.push(instruction.attributes[instruction.attrName]); } } } else { + //NO BINDINGS if (type) { + //templator or attached behavior found instruction = { attrName: attrName, type: type, attributes: {} }; instruction.attributes[resources.mapAttribute(attrName)] = attrValue; if (type.liftsContent) { + //template controller instruction.originalAttrName = attrName; liftingInstruction = instruction; break; } else { + //attached behavior behaviorInstructions.push(instruction); } } else if (elementProperty) { + //custom element attribute elementInstruction.attributes[attrName] = attrValue; } + + //else; normal attribute; do nothing } } @@ -297,4 +327,7 @@ var ViewCompiler = exports.ViewCompiler = (function () { return ViewCompiler; })(); -exports.__esModule = true; \ No newline at end of file + +Object.defineProperty(exports, "__esModule", { + value: true +}); \ No newline at end of file diff --git a/dist/commonjs/view-engine.js b/dist/commonjs/view-engine.js index 639f4c11..86e5b839 100644 --- a/dist/commonjs/view-engine.js +++ b/dist/commonjs/view-engine.js @@ -4,22 +4,28 @@ var _interopRequireWildcard = function (obj) { return obj && obj.__esModule ? ob var _prototypeProperties = function (child, staticProps, instanceProps) { if (staticProps) Object.defineProperties(child, staticProps); if (instanceProps) Object.defineProperties(child.prototype, instanceProps); }; +var _classCallCheck = function (instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }; + var LogManager = _interopRequireWildcard(require("aurelia-logging")); var Loader = require("aurelia-loader").Loader; + var relativeToFile = require("aurelia-path").relativeToFile; + var ViewCompiler = require("./view-compiler").ViewCompiler; + var _resourceRegistry = require("./resource-registry"); var ResourceRegistry = _resourceRegistry.ResourceRegistry; var ViewResources = _resourceRegistry.ViewResources; - var importSplitter = /\s*,\s*/, logger = LogManager.getLogger("templating"); var ViewEngine = exports.ViewEngine = (function () { function ViewEngine(loader, viewCompiler, appResources) { + _classCallCheck(this, ViewEngine); + this.loader = loader; this.viewCompiler = viewCompiler; this.appResources = appResources; @@ -38,6 +44,7 @@ var ViewEngine = exports.ViewEngine = (function () { loadViewFactory: { value: function loadViewFactory(url, compileOptions, associatedModuleId) { var _this = this; + var existing = this.importedViews[url]; if (existing) { return Promise.resolve(existing); @@ -62,6 +69,7 @@ var ViewEngine = exports.ViewEngine = (function () { loadTemplateResources: { value: function loadTemplateResources(templateUrl, template, associatedModuleId) { var _this = this; + var importIds, names, i, @@ -123,4 +131,7 @@ var ViewEngine = exports.ViewEngine = (function () { return ViewEngine; })(); -exports.__esModule = true; \ No newline at end of file + +Object.defineProperty(exports, "__esModule", { + value: true +}); \ No newline at end of file diff --git a/dist/commonjs/view-factory.js b/dist/commonjs/view-factory.js index 4402a002..acada68f 100644 --- a/dist/commonjs/view-factory.js +++ b/dist/commonjs/view-factory.js @@ -2,12 +2,17 @@ var _prototypeProperties = function (child, staticProps, instanceProps) { if (staticProps) Object.defineProperties(child, staticProps); if (instanceProps) Object.defineProperties(child.prototype, instanceProps); }; +var _classCallCheck = function (instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }; + var Container = require("aurelia-dependency-injection").Container; + var View = require("./view").View; + var ViewSlot = require("./view-slot").ViewSlot; + var ContentSelector = require("./content-selector").ContentSelector; -var ViewResources = require("./resource-registry").ViewResources; +var ViewResources = require("./resource-registry").ViewResources; function elementContainerGet(key) { if (key === Element) { @@ -100,6 +105,8 @@ function applyInstructions(containers, executionContext, element, instruction, b var BoundViewFactory = exports.BoundViewFactory = (function () { function BoundViewFactory(parentContainer, viewFactory, executionContext) { + _classCallCheck(this, BoundViewFactory); + this.parentContainer = parentContainer; this.viewFactory = viewFactory; this.executionContext = executionContext; @@ -124,7 +131,6 @@ var BoundViewFactory = exports.BoundViewFactory = (function () { return BoundViewFactory; })(); - var defaultFactoryOptions = { systemControlled: false, suppressBind: false @@ -132,6 +138,8 @@ var defaultFactoryOptions = { var ViewFactory = exports.ViewFactory = (function () { function ViewFactory(template, instructions, resources) { + _classCallCheck(this, ViewFactory); + this.template = template; this.instructions = instructions; this.resources = resources; @@ -141,6 +149,7 @@ var ViewFactory = exports.ViewFactory = (function () { create: { value: function create(container, executionContext) { var options = arguments[2] === undefined ? defaultFactoryOptions : arguments[2]; + var fragment = this.template.cloneNode(true), instructables = fragment.querySelectorAll(".au-target"), instructions = this.instructions, @@ -174,4 +183,7 @@ var ViewFactory = exports.ViewFactory = (function () { return ViewFactory; })(); -exports.__esModule = true; \ No newline at end of file + +Object.defineProperty(exports, "__esModule", { + value: true +}); \ No newline at end of file diff --git a/dist/commonjs/view-slot.js b/dist/commonjs/view-slot.js index bbc8c6d7..2cec4fd8 100644 --- a/dist/commonjs/view-slot.js +++ b/dist/commonjs/view-slot.js @@ -2,16 +2,25 @@ var _prototypeProperties = function (child, staticProps, instanceProps) { if (staticProps) Object.defineProperties(child, staticProps); if (instanceProps) Object.defineProperties(child.prototype, instanceProps); }; +var _classCallCheck = function (instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }; + var ContentSelector = require("./content-selector").ContentSelector; + +var Animator = require("./animator").Animator; + var ViewSlot = exports.ViewSlot = (function () { function ViewSlot(anchor, anchorIsContainer, executionContext) { + var animator = arguments[3] === undefined ? Animator.instance : arguments[3]; + + _classCallCheck(this, ViewSlot); + this.anchor = anchor; this.viewAddMethod = anchorIsContainer ? "appendNodesTo" : "insertNodesBefore"; this.executionContext = executionContext; + this.animator = animator; this.children = []; this.isBound = false; this.isAttached = false; - anchor.viewSlot = this; } @@ -21,6 +30,9 @@ var ViewSlot = exports.ViewSlot = (function () { var parent = this.anchor; this.children.push({ + fragment: parent, + firstChild: parent.firstChild, + lastChild: parent.lastChild, removeNodes: function removeNodes() { var last; @@ -82,6 +94,11 @@ var ViewSlot = exports.ViewSlot = (function () { if (this.isAttached) { view.attached(); + // Animate page itself + var element = view.firstChild.nextElementSibling; + if (view.firstChild.nodeType === 8 && element !== undefined && element.nodeType === 1 && element.classList.contains("au-animate")) { + this.animator.enter(element); + } } }, writable: true, @@ -106,6 +123,7 @@ var ViewSlot = exports.ViewSlot = (function () { remove: { value: function remove(view) { view.removeNodes(); + this.children.splice(this.children.indexOf(view), 1); if (this.isAttached) { @@ -117,45 +135,87 @@ var ViewSlot = exports.ViewSlot = (function () { }, removeAt: { value: function removeAt(index) { + var _this = this; + var view = this.children[index]; - view.removeNodes(); - this.children.splice(index, 1); + var removeAction = function () { + view.removeNodes(); + _this.children.splice(index, 1); - if (this.isAttached) { - view.detached(); - } + if (_this.isAttached) { + view.detached(); + } - return view; + return view; + }; + + var element = view.firstChild.nextElementSibling; + if (view.firstChild.nodeType === 8 && element !== undefined && element.nodeType === 1 && element.classList.contains("au-animate")) { + return this.animator.leave(element).then(function () { + return removeAction(); + }); + } else { + return removeAction(); + } }, writable: true, configurable: true }, removeAll: { value: function removeAll() { + var _this = this; + var children = this.children, ii = children.length, i; - for (i = 0; i < ii; ++i) { - children[i].removeNodes(); - } + var rmPromises = []; - if (this.isAttached) { - for (i = 0; i < ii; ++i) { - children[i].detached(); + children.forEach(function (child) { + var element = child.firstChild.nextElementSibling; + if (child.firstChild !== undefined && child.firstChild.nodeType === 8 && element !== undefined && element.nodeType === 1 && element.classList.contains("au-animate")) { + rmPromises.push(_this.animator.leave(element).then(function () { + child.removeNodes(); + })); + } else { + child.removeNodes(); } - } + }); - this.children = []; + var removeAction = function () { + if (_this.isAttached) { + for (i = 0; i < ii; ++i) { + children[i].detached(); + } + } + + _this.children = []; + }; + + if (rmPromises.length > 0) { + return Promise.all(rmPromises).then(function () { + removeAction(); + }); + } else { + removeAction(); + } }, writable: true, configurable: true }, swap: { value: function swap(view) { - this.removeAll(); - this.add(view); + var _this = this; + + var removeResponse = this.removeAll(); + if (removeResponse !== undefined) { + removeResponse.then(function () { + _this.add(view); + }); + } else { + this.add(view); + } }, writable: true, configurable: true @@ -173,6 +233,11 @@ var ViewSlot = exports.ViewSlot = (function () { children = this.children; for (i = 0, ii = children.length; i < ii; ++i) { children[i].attached(); + + var element = children[i].firstChild.nextElementSibling; + if (children[i].firstChild.nodeType === 8 && element !== undefined && element.nodeType === 1 && element.classList.contains("au-animate")) { + this.animator.enter(element); + } } }, writable: true, @@ -314,4 +379,7 @@ var ViewSlot = exports.ViewSlot = (function () { return ViewSlot; })(); -exports.__esModule = true; \ No newline at end of file + +Object.defineProperty(exports, "__esModule", { + value: true +}); \ No newline at end of file diff --git a/dist/commonjs/view-strategy.js b/dist/commonjs/view-strategy.js index 6bb0dd93..18422309 100644 --- a/dist/commonjs/view-strategy.js +++ b/dist/commonjs/view-strategy.js @@ -4,13 +4,19 @@ var _inherits = function (subClass, superClass) { if (typeof superClass !== "fun var _prototypeProperties = function (child, staticProps, instanceProps) { if (staticProps) Object.defineProperties(child, staticProps); if (instanceProps) Object.defineProperties(child.prototype, instanceProps); }; +var _classCallCheck = function (instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }; + var _aureliaMetadata = require("aurelia-metadata"); var Metadata = _aureliaMetadata.Metadata; var Origin = _aureliaMetadata.Origin; + var relativeToFile = require("aurelia-path").relativeToFile; + var ViewStrategy = exports.ViewStrategy = (function () { - function ViewStrategy() {} + function ViewStrategy() { + _classCallCheck(this, ViewStrategy); + } _prototypeProperties(ViewStrategy, { normalize: { @@ -71,8 +77,11 @@ var ViewStrategy = exports.ViewStrategy = (function () { return ViewStrategy; })(); + var UseView = exports.UseView = (function (ViewStrategy) { function UseView(path) { + _classCallCheck(this, UseView); + this.path = path; } @@ -101,8 +110,11 @@ var UseView = exports.UseView = (function (ViewStrategy) { return UseView; })(ViewStrategy); + var ConventionalView = exports.ConventionalView = (function (ViewStrategy) { function ConventionalView(moduleId) { + _classCallCheck(this, ConventionalView); + this.moduleId = moduleId; this.viewUrl = ConventionalView.convertModuleIdToViewUrl(moduleId); } @@ -129,10 +141,13 @@ var ConventionalView = exports.ConventionalView = (function (ViewStrategy) { return ConventionalView; })(ViewStrategy); + var NoView = exports.NoView = (function (ViewStrategy) { function NoView() { - if (Object.getPrototypeOf(NoView) !== null) { - Object.getPrototypeOf(NoView).apply(this, arguments); + _classCallCheck(this, NoView); + + if (ViewStrategy != null) { + ViewStrategy.apply(this, arguments); } } @@ -150,4 +165,7 @@ var NoView = exports.NoView = (function (ViewStrategy) { return NoView; })(ViewStrategy); -exports.__esModule = true; \ No newline at end of file + +Object.defineProperty(exports, "__esModule", { + value: true +}); \ No newline at end of file diff --git a/dist/commonjs/view.js b/dist/commonjs/view.js index 6402df7a..183bd6bd 100644 --- a/dist/commonjs/view.js +++ b/dist/commonjs/view.js @@ -2,8 +2,15 @@ var _prototypeProperties = function (child, staticProps, instanceProps) { if (staticProps) Object.defineProperties(child, staticProps); if (instanceProps) Object.defineProperties(child.prototype, instanceProps); }; +var _classCallCheck = function (instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }; + +//NOTE: Adding a fragment to the document causes the nodes to be removed from the fragment. +//NOTE: Adding to the fragment, causes the nodes to be removed from the document. + var View = exports.View = (function () { function View(fragment, behaviors, bindings, children, systemControlled, contentSelectors) { + _classCallCheck(this, View); + this.fragment = fragment; this.behaviors = behaviors; this.bindings = bindings; @@ -208,4 +215,7 @@ var View = exports.View = (function () { return View; })(); -exports.__esModule = true; \ No newline at end of file + +Object.defineProperty(exports, "__esModule", { + value: true +}); \ No newline at end of file diff --git a/dist/es6/animator.js b/dist/es6/animator.js new file mode 100644 index 00000000..33937a3a --- /dev/null +++ b/dist/es6/animator.js @@ -0,0 +1,48 @@ +export class Animator { + constructor() { + Animator.instance = this; + this.animationStack = []; + } + + addMultipleEventListener(el, s, fn) { + var evts = s.split(' '), + i, ii; + + for (i = 0, ii = evts.length; i < ii; ++i) { + el.addEventListener(evts[i], fn, false); + } + } + + addAnimationToStack(animId) { + if(this.animationStack.indexOf(animId) < 0) { + this.animationStack.push(animId); + } + } + + removeAnimationFromStack(animId) { + var idx = this.animationStack.indexOf(animId); + if(idx > -1) { + this.animationStack.splice(idx, 1); + } + } + + move() { + return Promise.resolve(false); + } + + enter(element) { + return Promise.resolve(false); + } + + leave(element) { + return Promise.resolve(false); + } + + removeClass(element, className) { + return Promise.resolve(false); + } + + addClass(element, className) { + return Promise.resolve(false); + } +} diff --git a/dist/es6/index.js b/dist/es6/index.js index e7bf675a..49b7fc73 100644 --- a/dist/es6/index.js +++ b/dist/es6/index.js @@ -22,8 +22,10 @@ export {ViewFactory, BoundViewFactory} from './view-factory'; export {ViewSlot} from './view-slot'; export {BindingLanguage} from './binding-language'; export {CompositionEngine} from './composition-engine'; +export {Animator} from './animator'; export var Behavior = Metadata; +export var Behaviour = Metadata; Metadata.configure.classHelper('withProperty', BehaviorProperty); Metadata.configure.classHelper('withOptions', OptionsProperty); diff --git a/dist/es6/property.js b/dist/es6/property.js index 79168e0a..628b7b8e 100644 --- a/dist/es6/property.js +++ b/dist/es6/property.js @@ -26,7 +26,7 @@ export class BehaviorProperty { } define(taskQueue, behavior){ - var that = this, + var that = this, handlerName; this.taskQueue = taskQueue; @@ -55,7 +55,7 @@ export class BehaviorProperty { createObserver(executionContext){ var selfSubscriber = null; - + if(this.changeHandler){ selfSubscriber = (newValue, oldValue) => executionContext[this.changeHandler](newValue, oldValue); } @@ -151,8 +151,8 @@ export class OptionsProperty extends BehaviorProperty { } observer = observerLookup[name] = new BehaviorPropertyObserver( - this.taskQueue, - executionContext, + this.taskQueue, + executionContext, name, selfSubscriber ); @@ -238,4 +238,4 @@ class BehaviorPropertyObserver { callbacks.splice(callbacks.indexOf(callback), 1); }; } -} \ No newline at end of file +} diff --git a/dist/es6/view-compiler.js b/dist/es6/view-compiler.js index 46a85ee3..c7759d63 100644 --- a/dist/es6/view-compiler.js +++ b/dist/es6/view-compiler.js @@ -82,7 +82,7 @@ export class ViewCompiler { if(expression){ var marker = document.createElement('au-marker'); marker.className = 'au-target'; - node.parentNode.insertBefore(marker, node); + (node.parentNode || parentNode).insertBefore(marker, node); node.textContent = ' '; instructions.push({ contentExpression:expression }); } diff --git a/dist/es6/view-slot.js b/dist/es6/view-slot.js index cbdade57..0fe3ffd4 100644 --- a/dist/es6/view-slot.js +++ b/dist/es6/view-slot.js @@ -1,14 +1,15 @@ import {ContentSelector} from './content-selector'; +import {Animator} from './animator'; export class ViewSlot { - constructor(anchor, anchorIsContainer, executionContext){ + constructor(anchor, anchorIsContainer, executionContext, animator=Animator.instance){ this.anchor = anchor; this.viewAddMethod = anchorIsContainer ? 'appendNodesTo' : 'insertNodesBefore'; this.executionContext = executionContext; + this.animator = animator; this.children = []; this.isBound = false; this.isAttached = false; - anchor.viewSlot = this; } @@ -16,6 +17,9 @@ export class ViewSlot { var parent = this.anchor; this.children.push({ + fragment:parent, + firstChild:parent.firstChild, + lastChild:parent.lastChild, removeNodes(){ var last; @@ -66,6 +70,14 @@ export class ViewSlot { if(this.isAttached){ view.attached(); + // Animate page itself + var element = view.firstChild.nextElementSibling; + if(view.firstChild.nodeType === 8 && + element !== undefined && + element.nodeType === 1 && + element.classList.contains('au-animate')) { + this.animator.enter(element); + } } } @@ -84,6 +96,7 @@ export class ViewSlot { remove(view){ view.removeNodes(); + this.children.splice(this.children.indexOf(view), 1); if(this.isAttached){ @@ -94,14 +107,28 @@ export class ViewSlot { removeAt(index){ var view = this.children[index]; - view.removeNodes(); - this.children.splice(index, 1); + var removeAction = () => { + view.removeNodes(); + this.children.splice(index, 1); - if(this.isAttached){ - view.detached(); - } + if(this.isAttached){ + view.detached(); + } - return view; + return view; + }; + + var element = view.firstChild.nextElementSibling; + if(view.firstChild.nodeType === 8 && + element !== undefined && + element.nodeType === 1 && + element.classList.contains('au-animate')) { + return this.animator.leave(element).then( () => { + return removeAction(); + }) + } else { + return removeAction(); + } } removeAll(){ @@ -109,22 +136,51 @@ export class ViewSlot { ii = children.length, i; - for(i = 0; i < ii; ++i){ - children[i].removeNodes(); - } + var rmPromises = []; + + children.forEach( (child) => { + var element = child.firstChild.nextElementSibling; + if(child.firstChild !== undefined && + child.firstChild.nodeType === 8 && + element !== undefined && + element.nodeType === 1 && + element.classList.contains('au-animate')) { + rmPromises.push(this.animator.leave(element).then( () => { + child.removeNodes(); + })); + } else { + child.removeNodes(); + } + }); - if(this.isAttached){ - for(i = 0; i < ii; ++i){ - children[i].detached(); + var removeAction = () => { + if(this.isAttached){ + for(i = 0; i < ii; ++i){ + children[i].detached(); + } } - } - this.children = []; + this.children = []; + }; + + if(rmPromises.length > 0) { + return Promise.all(rmPromises).then( () => { + removeAction(); + }); + } else { + removeAction(); + } } swap(view){ - this.removeAll(); - this.add(view); + var removeResponse = this.removeAll(); + if(removeResponse !== undefined) { + removeResponse.then(() => { + this.add(view); + }); + } else { + this.add(view); + } } attached(){ @@ -139,6 +195,14 @@ export class ViewSlot { children = this.children; for(i = 0, ii = children.length; i < ii; ++i){ children[i].attached(); + + var element = children[i].firstChild.nextElementSibling; + if(children[i].firstChild.nodeType === 8 && + element !== undefined && + element.nodeType === 1 && + element.classList.contains('au-animate')) { + this.animator.enter(element); + } } } @@ -165,7 +229,7 @@ export class ViewSlot { contentSelectorAdd(view){ ContentSelector.applySelectors( - view, + view, this.contentSelectors, (contentSelector, group) => contentSelector.add(group) ); @@ -182,7 +246,7 @@ export class ViewSlot { this.add(view); } else{ ContentSelector.applySelectors( - view, + view, this.contentSelectors, (contentSelector, group) => contentSelector.insert(index, group) ); @@ -199,7 +263,7 @@ export class ViewSlot { var index = this.children.indexOf(view), contentSelectors = this.contentSelectors, i, ii; - + for(i = 0, ii = contentSelectors.length; i < ii; ++i){ contentSelectors[i].removeAt(index, view.fragment); } @@ -252,4 +316,4 @@ export class ViewSlot { this.children = []; } -} \ No newline at end of file +} diff --git a/dist/system/animator.js b/dist/system/animator.js new file mode 100644 index 00000000..97b7885b --- /dev/null +++ b/dist/system/animator.js @@ -0,0 +1,95 @@ +System.register([], function (_export) { + var _prototypeProperties, _classCallCheck, Animator; + + return { + setters: [], + execute: function () { + "use strict"; + + _prototypeProperties = function (child, staticProps, instanceProps) { if (staticProps) Object.defineProperties(child, staticProps); if (instanceProps) Object.defineProperties(child.prototype, instanceProps); }; + + _classCallCheck = function (instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }; + + Animator = _export("Animator", (function () { + function Animator() { + _classCallCheck(this, Animator); + + Animator.instance = this; + this.animationStack = []; + } + + _prototypeProperties(Animator, null, { + addMultipleEventListener: { + value: function addMultipleEventListener(el, s, fn) { + var evts = s.split(" "), + i, + ii; + + for (i = 0, ii = evts.length; i < ii; ++i) { + el.addEventListener(evts[i], fn, false); + } + }, + writable: true, + configurable: true + }, + addAnimationToStack: { + value: function addAnimationToStack(animId) { + if (this.animationStack.indexOf(animId) < 0) { + this.animationStack.push(animId); + } + }, + writable: true, + configurable: true + }, + removeAnimationFromStack: { + value: function removeAnimationFromStack(animId) { + var idx = this.animationStack.indexOf(animId); + if (idx > -1) { + this.animationStack.splice(idx, 1); + } + }, + writable: true, + configurable: true + }, + move: { + value: function move() { + return Promise.resolve(false); + }, + writable: true, + configurable: true + }, + enter: { + value: function enter(element) { + return Promise.resolve(false); + }, + writable: true, + configurable: true + }, + leave: { + value: function leave(element) { + return Promise.resolve(false); + }, + writable: true, + configurable: true + }, + removeClass: { + value: function removeClass(element, className) { + return Promise.resolve(false); + }, + writable: true, + configurable: true + }, + addClass: { + value: function addClass(element, className) { + return Promise.resolve(false); + }, + writable: true, + configurable: true + } + }); + + return Animator; + })()); + } + }; +}); \ No newline at end of file diff --git a/dist/system/attached-behavior.js b/dist/system/attached-behavior.js index 4776957b..00761371 100644 --- a/dist/system/attached-behavior.js +++ b/dist/system/attached-behavior.js @@ -1,7 +1,6 @@ System.register(["aurelia-metadata", "./behavior-instance", "./behaviors", "./util"], function (_export) { - "use strict"; + var ResourceType, BehaviorInstance, configureBehavior, hyphenate, _prototypeProperties, _inherits, _classCallCheck, AttachedBehavior; - var ResourceType, BehaviorInstance, configureBehavior, hyphenate, _prototypeProperties, _inherits, AttachedBehavior; return { setters: [function (_aureliaMetadata) { ResourceType = _aureliaMetadata.ResourceType; @@ -13,12 +12,18 @@ System.register(["aurelia-metadata", "./behavior-instance", "./behaviors", "./ut hyphenate = _util.hyphenate; }], execute: function () { + "use strict"; + _prototypeProperties = function (child, staticProps, instanceProps) { if (staticProps) Object.defineProperties(child, staticProps); if (instanceProps) Object.defineProperties(child.prototype, instanceProps); }; _inherits = function (subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) subClass.__proto__ = superClass; }; + _classCallCheck = function (instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }; + AttachedBehavior = _export("AttachedBehavior", (function (ResourceType) { function AttachedBehavior(attribute) { + _classCallCheck(this, AttachedBehavior); + this.name = attribute; this.properties = []; this.attributes = {}; diff --git a/dist/system/behavior-instance.js b/dist/system/behavior-instance.js index d23465b1..933d15bb 100644 --- a/dist/system/behavior-instance.js +++ b/dist/system/behavior-instance.js @@ -1,14 +1,19 @@ System.register([], function (_export) { - "use strict"; + var _prototypeProperties, _classCallCheck, BehaviorInstance; - var _prototypeProperties, BehaviorInstance; return { setters: [], execute: function () { + "use strict"; + _prototypeProperties = function (child, staticProps, instanceProps) { if (staticProps) Object.defineProperties(child, staticProps); if (instanceProps) Object.defineProperties(child.prototype, instanceProps); }; + _classCallCheck = function (instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }; + BehaviorInstance = _export("BehaviorInstance", (function () { function BehaviorInstance(behavior, executionContext, instruction) { + _classCallCheck(this, BehaviorInstance); + this.behavior = behavior; this.executionContext = executionContext; diff --git a/dist/system/behaviors.js b/dist/system/behaviors.js index df53a3b4..535cccf3 100644 --- a/dist/system/behaviors.js +++ b/dist/system/behaviors.js @@ -1,7 +1,6 @@ System.register(["aurelia-metadata", "aurelia-task-queue", "aurelia-binding", "./children", "./property", "./util"], function (_export) { - "use strict"; - var Metadata, TaskQueue, ObserverLocator, ChildObserver, BehaviorProperty, hyphenate; + _export("configureBehavior", configureBehavior); function configureBehavior(container, behavior, target, valuePropertyName) { @@ -59,6 +58,7 @@ System.register(["aurelia-metadata", "aurelia-task-queue", "aurelia-binding", ". behavior.childExpression = meta.first(ChildObserver); } + return { setters: [function (_aureliaMetadata) { Metadata = _aureliaMetadata.Metadata; @@ -73,6 +73,8 @@ System.register(["aurelia-metadata", "aurelia-task-queue", "aurelia-binding", ". }, function (_util) { hyphenate = _util.hyphenate; }], - execute: function () {} + execute: function () { + "use strict"; + } }; }); \ No newline at end of file diff --git a/dist/system/binding-language.js b/dist/system/binding-language.js index cb92c302..ba72ed58 100644 --- a/dist/system/binding-language.js +++ b/dist/system/binding-language.js @@ -1,14 +1,19 @@ System.register([], function (_export) { - "use strict"; + var _prototypeProperties, _classCallCheck, BindingLanguage; - var _prototypeProperties, BindingLanguage; return { setters: [], execute: function () { + "use strict"; + _prototypeProperties = function (child, staticProps, instanceProps) { if (staticProps) Object.defineProperties(child, staticProps); if (instanceProps) Object.defineProperties(child.prototype, instanceProps); }; + _classCallCheck = function (instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }; + BindingLanguage = _export("BindingLanguage", (function () { - function BindingLanguage() {} + function BindingLanguage() { + _classCallCheck(this, BindingLanguage); + } _prototypeProperties(BindingLanguage, null, { inspectAttribute: { diff --git a/dist/system/children.js b/dist/system/children.js index 64eadde5..1ef97def 100644 --- a/dist/system/children.js +++ b/dist/system/children.js @@ -1,139 +1,146 @@ System.register([], function (_export) { - "use strict"; - - var _prototypeProperties, noMutations, ChildObserver, ChildObserverBinder; - return { - setters: [], - execute: function () { - _prototypeProperties = function (child, staticProps, instanceProps) { if (staticProps) Object.defineProperties(child, staticProps); if (instanceProps) Object.defineProperties(child.prototype, instanceProps); }; - - noMutations = []; - ChildObserver = _export("ChildObserver", (function () { - function ChildObserver(property, changeHandler, selector) { - this.selector = selector; - this.changeHandler = changeHandler; - this.property = property; - } - - _prototypeProperties(ChildObserver, null, { - createBinding: { - value: function createBinding(target, behavior) { - return new ChildObserverBinder(this.selector, target, this.property, behavior, this.changeHandler); - }, - writable: true, - configurable: true - } - }); - - return ChildObserver; - })()); - ChildObserverBinder = _export("ChildObserverBinder", (function () { - function ChildObserverBinder(selector, target, property, behavior, changeHandler) { - this.selector = selector; - this.target = target; - this.property = property; - this.target = target; - this.behavior = behavior; - this.changeHandler = changeHandler; - this.observer = new MutationObserver(this.onChange.bind(this)); - } - - _prototypeProperties(ChildObserverBinder, null, { - bind: { - value: function bind(source) { - var items, - results, - i, - ii, - node, - behavior = this.behavior; - - this.observer.observe(this.target, { childList: true, subtree: true }); - - items = behavior[this.property]; - if (!items) { - items = behavior[this.property] = []; - } else { - items.length = 0; - } - - results = this.target.querySelectorAll(this.selector); - - for (i = 0, ii = results.length; i < ii; ++i) { - node = results[i]; - items.push(node.primaryBehavior ? node.primaryBehavior.executionContext : node); - } - - if (this.changeHandler) { - this.behavior[this.changeHandler](noMutations); - } - }, - writable: true, - configurable: true - }, - unbind: { - value: function unbind() { - this.observer.disconnect(); - }, - writable: true, - configurable: true - }, - onChange: { - value: function onChange(mutations) { - var items = this.behavior[this.property], - selector = this.selector; - - mutations.forEach(function (record) { - var added = record.addedNodes, - removed = record.removedNodes, - prev = record.previousSibling, - i, - ii, - primary, - index, - node; - - for (i = 0, ii = removed.length; i < ii; ++i) { - node = removed[i]; - if (node.nodeType === 1 && node.matches(selector)) { - primary = node.primaryBehavior ? node.primaryBehavior.executionContext : node; - index = items.indexOf(primary); - if (index != -1) { - items.splice(index, 1); - } - } - } - - for (i = 0, ii = added.length; i < ii; ++i) { - node = added[i]; - if (node.nodeType === 1 && node.matches(selector)) { - primary = node.primaryBehavior ? node.primaryBehavior.executionContext : node; - index = 0; - - while (prev) { - if (prev.nodeType === 1 && prev.matches(selector)) { - index++; - } - - prev = prev.previousSibling; - } - - items.splice(index, 0, primary); - } - } - }); - - if (this.changeHandler) { - this.behavior[this.changeHandler](mutations); - } - }, - writable: true, - configurable: true - } - }); - - return ChildObserverBinder; - })()); - } - }; + var _prototypeProperties, _classCallCheck, noMutations, ChildObserver, ChildObserverBinder; + + return { + setters: [], + execute: function () { + "use strict"; + + _prototypeProperties = function (child, staticProps, instanceProps) { if (staticProps) Object.defineProperties(child, staticProps); if (instanceProps) Object.defineProperties(child.prototype, instanceProps); }; + + _classCallCheck = function (instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }; + + noMutations = []; + ChildObserver = _export("ChildObserver", (function () { + function ChildObserver(property, changeHandler, selector) { + _classCallCheck(this, ChildObserver); + + this.selector = selector; + this.changeHandler = changeHandler; + this.property = property; + } + + _prototypeProperties(ChildObserver, null, { + createBinding: { + value: function createBinding(target, behavior) { + return new ChildObserverBinder(this.selector, target, this.property, behavior, this.changeHandler); + }, + writable: true, + configurable: true + } + }); + + return ChildObserver; + })()); + ChildObserverBinder = _export("ChildObserverBinder", (function () { + function ChildObserverBinder(selector, target, property, behavior, changeHandler) { + _classCallCheck(this, ChildObserverBinder); + + this.selector = selector; + this.target = target; + this.property = property; + this.target = target; + this.behavior = behavior; + this.changeHandler = changeHandler; + this.observer = new MutationObserver(this.onChange.bind(this)); + } + + _prototypeProperties(ChildObserverBinder, null, { + bind: { + value: function bind(source) { + var items, + results, + i, + ii, + node, + behavior = this.behavior; + + this.observer.observe(this.target, { childList: true, subtree: true }); + + items = behavior[this.property]; + if (!items) { + items = behavior[this.property] = []; + } else { + items.length = 0; + } + + results = this.target.querySelectorAll(this.selector); + + for (i = 0, ii = results.length; i < ii; ++i) { + node = results[i]; + items.push(node.primaryBehavior ? node.primaryBehavior.executionContext : node); + } + + if (this.changeHandler) { + this.behavior[this.changeHandler](noMutations); + } + }, + writable: true, + configurable: true + }, + unbind: { + value: function unbind() { + this.observer.disconnect(); + }, + writable: true, + configurable: true + }, + onChange: { + value: function onChange(mutations) { + var items = this.behavior[this.property], + selector = this.selector; + + mutations.forEach(function (record) { + var added = record.addedNodes, + removed = record.removedNodes, + prev = record.previousSibling, + i, + ii, + primary, + index, + node; + + for (i = 0, ii = removed.length; i < ii; ++i) { + node = removed[i]; + if (node.nodeType === 1 && node.matches(selector)) { + primary = node.primaryBehavior ? node.primaryBehavior.executionContext : node; + index = items.indexOf(primary); + if (index != -1) { + items.splice(index, 1); + } + } + } + + for (i = 0, ii = added.length; i < ii; ++i) { + node = added[i]; + if (node.nodeType === 1 && node.matches(selector)) { + primary = node.primaryBehavior ? node.primaryBehavior.executionContext : node; + index = 0; + + while (prev) { + if (prev.nodeType === 1 && prev.matches(selector)) { + index++; + } + + prev = prev.previousSibling; + } + + items.splice(index, 0, primary); + } + } + }); + + if (this.changeHandler) { + this.behavior[this.changeHandler](mutations); + } + }, + writable: true, + configurable: true + } + }); + + return ChildObserverBinder; + })()); + } + }; }); \ No newline at end of file diff --git a/dist/system/composition-engine.js b/dist/system/composition-engine.js index 3c808939..0bb63dc7 100644 --- a/dist/system/composition-engine.js +++ b/dist/system/composition-engine.js @@ -1,7 +1,6 @@ System.register(["aurelia-metadata", "aurelia-dependency-injection", "./view-strategy", "./resource-coordinator", "./view-engine", "./custom-element"], function (_export) { - "use strict"; + var Origin, Metadata, ViewStrategy, UseView, ResourceCoordinator, ViewEngine, CustomElement, _prototypeProperties, _classCallCheck, CompositionEngine; - var Origin, Metadata, ViewStrategy, UseView, ResourceCoordinator, ViewEngine, CustomElement, _prototypeProperties, CompositionEngine; return { setters: [function (_aureliaMetadata) { Origin = _aureliaMetadata.Origin; @@ -17,10 +16,16 @@ System.register(["aurelia-metadata", "aurelia-dependency-injection", "./view-str CustomElement = _customElement.CustomElement; }], execute: function () { + "use strict"; + _prototypeProperties = function (child, staticProps, instanceProps) { if (staticProps) Object.defineProperties(child, staticProps); if (instanceProps) Object.defineProperties(child.prototype, instanceProps); }; + _classCallCheck = function (instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }; + CompositionEngine = _export("CompositionEngine", (function () { function CompositionEngine(resourceCoordinator, viewEngine) { + _classCallCheck(this, CompositionEngine); + this.resourceCoordinator = resourceCoordinator; this.viewEngine = viewEngine; } @@ -119,6 +124,7 @@ System.register(["aurelia-metadata", "aurelia-dependency-injection", "./view-str compose: { value: function compose(instruction) { var _this = this; + instruction.childContainer = instruction.childContainer || instruction.container.createChild(); instruction.view = ViewStrategy.normalize(instruction.view); diff --git a/dist/system/content-selector.js b/dist/system/content-selector.js index a30ad0e0..a888de21 100644 --- a/dist/system/content-selector.js +++ b/dist/system/content-selector.js @@ -1,152 +1,156 @@ System.register([], function (_export) { - "use strict"; - - var _prototypeProperties, proto, placeholder, ContentSelector; - - - function findInsertionPoint(groups, index) { - var insertionPoint; - - while (!insertionPoint && index >= 0) { - insertionPoint = groups[index][0]; - index--; - } - - return insertionPoint || anchor; - } - - return { - setters: [], - execute: function () { - _prototypeProperties = function (child, staticProps, instanceProps) { if (staticProps) Object.defineProperties(child, staticProps); if (instanceProps) Object.defineProperties(child.prototype, instanceProps); }; - - if (Element && !Element.prototype.matches) { - proto = Element.prototype; - proto.matches = proto.matchesSelector || proto.mozMatchesSelector || proto.msMatchesSelector || proto.oMatchesSelector || proto.webkitMatchesSelector; - } - - placeholder = []; - ContentSelector = _export("ContentSelector", (function () { - function ContentSelector(anchor, selector) { - this.anchor = anchor; - this.selector = selector; - this.all = !this.selector; - this.groups = []; - } - - _prototypeProperties(ContentSelector, { - applySelectors: { - value: function applySelectors(view, contentSelectors, callback) { - var currentChild = view.fragment.firstChild, - contentMap = new Map(), - nextSibling, - i, - ii, - contentSelector; - - while (currentChild) { - nextSibling = currentChild.nextSibling; - - if (currentChild.viewSlot) { - var viewSlotSelectors = contentSelectors.map(function (x) { - return x.copyForViewSlot(); - }); - currentChild.viewSlot.installContentSelectors(viewSlotSelectors); - } else { - for (i = 0, ii = contentSelectors.length; i < ii; i++) { - contentSelector = contentSelectors[i]; - if (contentSelector.matches(currentChild)) { - var elements = contentMap.get(contentSelector); - if (!elements) { - elements = []; - contentMap.set(contentSelector, elements); - } - - elements.push(currentChild); - break; - } - } - } - - currentChild = nextSibling; - } - - for (i = 0, ii = contentSelectors.length; i < ii; ++i) { - contentSelector = contentSelectors[i]; - callback(contentSelector, contentMap.get(contentSelector) || placeholder); - } - }, - writable: true, - configurable: true - } - }, { - copyForViewSlot: { - value: function copyForViewSlot() { - return new ContentSelector(this.anchor, this.selector); - }, - writable: true, - configurable: true - }, - matches: { - value: function matches(node) { - return this.all || node.nodeType === 1 && node.matches(this.selector); - }, - writable: true, - configurable: true - }, - add: { - value: function add(group) { - var anchor = this.anchor, - parent = anchor.parentNode, - i, - ii; - - for (i = 0, ii = group.length; i < ii; ++i) { - parent.insertBefore(group[i], anchor); - } - - this.groups.push(group); - }, - writable: true, - configurable: true - }, - insert: { - value: function insert(index, group) { - if (group.length) { - var anchor = findInsertionPoint(this.groups, index) || this.anchor, - parent = anchor.parentNode, - i, - ii; - - for (i = 0, ii = group.length; i < ii; ++i) { - parent.insertBefore(group[i], anchor); - } - } - - this.groups.splice(index, 0, group); - }, - writable: true, - configurable: true - }, - removeAt: { - value: function removeAt(index, fragment) { - var group = this.groups[index], - i, - ii; - - for (i = 0, ii = group.length; i < ii; ++i) { - fragment.appendChild(group[i]); - } - - this.groups.splice(index, 1); - }, - writable: true, - configurable: true - } - }); - - return ContentSelector; - })()); - } - }; + var _prototypeProperties, _classCallCheck, proto, placeholder, ContentSelector; + + function findInsertionPoint(groups, index) { + var insertionPoint; + + while (!insertionPoint && index >= 0) { + insertionPoint = groups[index][0]; + index--; + } + + return insertionPoint || anchor; + } + + return { + setters: [], + execute: function () { + "use strict"; + + _prototypeProperties = function (child, staticProps, instanceProps) { if (staticProps) Object.defineProperties(child, staticProps); if (instanceProps) Object.defineProperties(child.prototype, instanceProps); }; + + _classCallCheck = function (instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }; + + if (Element && !Element.prototype.matches) { + proto = Element.prototype; + + proto.matches = proto.matchesSelector || proto.mozMatchesSelector || proto.msMatchesSelector || proto.oMatchesSelector || proto.webkitMatchesSelector; + } + + placeholder = []; + ContentSelector = _export("ContentSelector", (function () { + function ContentSelector(anchor, selector) { + _classCallCheck(this, ContentSelector); + + this.anchor = anchor; + this.selector = selector; + this.all = !this.selector; + this.groups = []; + } + + _prototypeProperties(ContentSelector, { + applySelectors: { + value: function applySelectors(view, contentSelectors, callback) { + var currentChild = view.fragment.firstChild, + contentMap = new Map(), + nextSibling, + i, + ii, + contentSelector; + + while (currentChild) { + nextSibling = currentChild.nextSibling; + + if (currentChild.viewSlot) { + var viewSlotSelectors = contentSelectors.map(function (x) { + return x.copyForViewSlot(); + }); + currentChild.viewSlot.installContentSelectors(viewSlotSelectors); + } else { + for (i = 0, ii = contentSelectors.length; i < ii; i++) { + contentSelector = contentSelectors[i]; + if (contentSelector.matches(currentChild)) { + var elements = contentMap.get(contentSelector); + if (!elements) { + elements = []; + contentMap.set(contentSelector, elements); + } + + elements.push(currentChild); + break; + } + } + } + + currentChild = nextSibling; + } + + for (i = 0, ii = contentSelectors.length; i < ii; ++i) { + contentSelector = contentSelectors[i]; + callback(contentSelector, contentMap.get(contentSelector) || placeholder); + } + }, + writable: true, + configurable: true + } + }, { + copyForViewSlot: { + value: function copyForViewSlot() { + return new ContentSelector(this.anchor, this.selector); + }, + writable: true, + configurable: true + }, + matches: { + value: function matches(node) { + return this.all || node.nodeType === 1 && node.matches(this.selector); + }, + writable: true, + configurable: true + }, + add: { + value: function add(group) { + var anchor = this.anchor, + parent = anchor.parentNode, + i, + ii; + + for (i = 0, ii = group.length; i < ii; ++i) { + parent.insertBefore(group[i], anchor); + } + + this.groups.push(group); + }, + writable: true, + configurable: true + }, + insert: { + value: function insert(index, group) { + if (group.length) { + var anchor = findInsertionPoint(this.groups, index) || this.anchor, + parent = anchor.parentNode, + i, + ii; + + for (i = 0, ii = group.length; i < ii; ++i) { + parent.insertBefore(group[i], anchor); + } + } + + this.groups.splice(index, 0, group); + }, + writable: true, + configurable: true + }, + removeAt: { + value: function removeAt(index, fragment) { + var group = this.groups[index], + i, + ii; + + for (i = 0, ii = group.length; i < ii; ++i) { + fragment.appendChild(group[i]); + } + + this.groups.splice(index, 1); + }, + writable: true, + configurable: true + } + }); + + return ContentSelector; + })()); + } + }; }); \ No newline at end of file diff --git a/dist/system/custom-element.js b/dist/system/custom-element.js index 6bada1f7..28d73dc4 100644 --- a/dist/system/custom-element.js +++ b/dist/system/custom-element.js @@ -1,7 +1,6 @@ System.register(["aurelia-metadata", "./behavior-instance", "./behaviors", "./content-selector", "./view-engine", "./view-strategy", "./util"], function (_export) { - "use strict"; + var Metadata, Origin, ResourceType, BehaviorInstance, configureBehavior, ContentSelector, ViewEngine, ViewStrategy, hyphenate, _prototypeProperties, _inherits, _classCallCheck, defaultInstruction, contentSelectorFactoryOptions, hasShadowDOM, valuePropertyName, UseShadowDOM, SkipContentProcessing, CustomElement; - var Metadata, Origin, ResourceType, BehaviorInstance, configureBehavior, ContentSelector, ViewEngine, ViewStrategy, hyphenate, _prototypeProperties, _inherits, defaultInstruction, contentSelectorFactoryOptions, hasShadowDOM, valuePropertyName, UseShadowDOM, SkipContentProcessing, CustomElement; return { setters: [function (_aureliaMetadata) { Metadata = _aureliaMetadata.Metadata; @@ -21,18 +20,28 @@ System.register(["aurelia-metadata", "./behavior-instance", "./behaviors", "./co hyphenate = _util.hyphenate; }], execute: function () { + "use strict"; + _prototypeProperties = function (child, staticProps, instanceProps) { if (staticProps) Object.defineProperties(child, staticProps); if (instanceProps) Object.defineProperties(child.prototype, instanceProps); }; _inherits = function (subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) subClass.__proto__ = superClass; }; + _classCallCheck = function (instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }; + defaultInstruction = { suppressBind: false }; contentSelectorFactoryOptions = { suppressBind: true }; hasShadowDOM = !!HTMLElement.prototype.createShadowRoot; valuePropertyName = "value"; - UseShadowDOM = _export("UseShadowDOM", function UseShadowDOM() {}); - SkipContentProcessing = _export("SkipContentProcessing", function SkipContentProcessing() {}); + UseShadowDOM = _export("UseShadowDOM", function UseShadowDOM() { + _classCallCheck(this, UseShadowDOM); + }); + SkipContentProcessing = _export("SkipContentProcessing", function SkipContentProcessing() { + _classCallCheck(this, SkipContentProcessing); + }); CustomElement = _export("CustomElement", (function (ResourceType) { function CustomElement(tagName) { + _classCallCheck(this, CustomElement); + this.name = tagName; this.properties = []; this.attributes = {}; @@ -67,6 +76,7 @@ System.register(["aurelia-metadata", "./behavior-instance", "./behaviors", "./co load: { value: function load(container, target, viewStrategy) { var _this = this; + var options; viewStrategy = viewStrategy || ViewStrategy.getDefault(target); @@ -121,6 +131,7 @@ System.register(["aurelia-metadata", "./behavior-instance", "./behaviors", "./co value: function create(container) { var instruction = arguments[1] === undefined ? defaultInstruction : arguments[1]; var element = arguments[2] === undefined ? null : arguments[2]; + var executionContext = instruction.executionContext || container.get(this.target), behaviorInstance = new BehaviorInstance(this, executionContext, instruction), host; diff --git a/dist/system/element-config.js b/dist/system/element-config.js index d7203ed1..3188f95c 100644 --- a/dist/system/element-config.js +++ b/dist/system/element-config.js @@ -1,7 +1,6 @@ System.register(["aurelia-metadata", "aurelia-binding"], function (_export) { - "use strict"; + var ResourceType, EventManager, _prototypeProperties, _inherits, _classCallCheck, ElementConfig; - var ResourceType, EventManager, _prototypeProperties, _inherits, ElementConfig; return { setters: [function (_aureliaMetadata) { ResourceType = _aureliaMetadata.ResourceType; @@ -9,14 +8,20 @@ System.register(["aurelia-metadata", "aurelia-binding"], function (_export) { EventManager = _aureliaBinding.EventManager; }], execute: function () { + "use strict"; + _prototypeProperties = function (child, staticProps, instanceProps) { if (staticProps) Object.defineProperties(child, staticProps); if (instanceProps) Object.defineProperties(child.prototype, instanceProps); }; _inherits = function (subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) subClass.__proto__ = superClass; }; + _classCallCheck = function (instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }; + ElementConfig = _export("ElementConfig", (function (ResourceType) { function ElementConfig() { - if (Object.getPrototypeOf(ElementConfig) !== null) { - Object.getPrototypeOf(ElementConfig).apply(this, arguments); + _classCallCheck(this, ElementConfig); + + if (ResourceType != null) { + ResourceType.apply(this, arguments); } } diff --git a/dist/system/index.js b/dist/system/index.js index 6873aa6f..88645705 100644 --- a/dist/system/index.js +++ b/dist/system/index.js @@ -1,26 +1,28 @@ -System.register(["aurelia-metadata", "./property", "./attached-behavior", "./children", "./custom-element", "./element-config", "./template-controller", "./view-strategy", "./resource-coordinator", "./resource-registry", "./view-compiler", "./view-engine", "./view-factory", "./view-slot", "./binding-language", "./composition-engine"], function (_export) { - "use strict"; - - var Metadata, BehaviorProperty, OptionsProperty, AttachedBehavior, ChildObserver, CustomElement, UseShadowDOM, SkipContentProcessing, ElementConfig, TemplateController, UseView, NoView, Behavior; +System.register(["aurelia-metadata", "./property", "./attached-behavior", "./children", "./custom-element", "./element-config", "./template-controller", "./view-strategy", "./resource-coordinator", "./resource-registry", "./view-compiler", "./view-engine", "./view-factory", "./view-slot", "./binding-language", "./composition-engine", "./animator"], function (_export) { + var Metadata, BehaviorProperty, OptionsProperty, AttachedBehavior, ChildObserver, CustomElement, UseShadowDOM, SkipContentProcessing, ElementConfig, TemplateController, UseView, NoView, Behavior, Behaviour; return { setters: [function (_aureliaMetadata) { Metadata = _aureliaMetadata.Metadata; }, function (_property) { BehaviorProperty = _property.BehaviorProperty; OptionsProperty = _property.OptionsProperty; + _export("BehaviorProperty", _property.BehaviorProperty); _export("OptionsProperty", _property.OptionsProperty); }, function (_attachedBehavior) { AttachedBehavior = _attachedBehavior.AttachedBehavior; + _export("AttachedBehavior", _attachedBehavior.AttachedBehavior); }, function (_children) { ChildObserver = _children.ChildObserver; + _export("ChildObserver", _children.ChildObserver); }, function (_customElement) { CustomElement = _customElement.CustomElement; UseShadowDOM = _customElement.UseShadowDOM; SkipContentProcessing = _customElement.SkipContentProcessing; + _export("CustomElement", _customElement.CustomElement); _export("UseShadowDOM", _customElement.UseShadowDOM); @@ -28,13 +30,16 @@ System.register(["aurelia-metadata", "./property", "./attached-behavior", "./chi _export("SkipContentProcessing", _customElement.SkipContentProcessing); }, function (_elementConfig) { ElementConfig = _elementConfig.ElementConfig; + _export("ElementConfig", _elementConfig.ElementConfig); }, function (_templateController) { TemplateController = _templateController.TemplateController; + _export("TemplateController", _templateController.TemplateController); }, function (_viewStrategy) { UseView = _viewStrategy.UseView; NoView = _viewStrategy.NoView; + _export("ViewStrategy", _viewStrategy.ViewStrategy); _export("UseView", _viewStrategy.UseView); @@ -62,10 +67,14 @@ System.register(["aurelia-metadata", "./property", "./attached-behavior", "./chi _export("BindingLanguage", _bindingLanguage.BindingLanguage); }, function (_compositionEngine) { _export("CompositionEngine", _compositionEngine.CompositionEngine); + }, function (_animator) { + _export("Animator", _animator.Animator); }], execute: function () { - Behavior = _export("Behavior", Metadata); + "use strict"; + Behavior = _export("Behavior", Metadata); + Behaviour = _export("Behaviour", Metadata); Metadata.configure.classHelper("withProperty", BehaviorProperty); Metadata.configure.classHelper("withOptions", OptionsProperty); diff --git a/dist/system/property.js b/dist/system/property.js index 9b87ac2c..f593bef0 100644 --- a/dist/system/property.js +++ b/dist/system/property.js @@ -1,7 +1,6 @@ System.register(["./util", "aurelia-binding"], function (_export) { - "use strict"; + var hyphenate, ONE_WAY, TWO_WAY, ONE_TIME, _inherits, _prototypeProperties, _classCallCheck, BehaviorProperty, OptionsProperty, BehaviorPropertyObserver; - var hyphenate, ONE_WAY, TWO_WAY, ONE_TIME, _inherits, _prototypeProperties, BehaviorProperty, OptionsProperty, BehaviorPropertyObserver; return { setters: [function (_util) { hyphenate = _util.hyphenate; @@ -11,12 +10,18 @@ System.register(["./util", "aurelia-binding"], function (_export) { ONE_TIME = _aureliaBinding.ONE_TIME; }], execute: function () { + "use strict"; + _inherits = function (subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) subClass.__proto__ = superClass; }; _prototypeProperties = function (child, staticProps, instanceProps) { if (staticProps) Object.defineProperties(child, staticProps); if (instanceProps) Object.defineProperties(child.prototype, instanceProps); }; + _classCallCheck = function (instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }; + BehaviorProperty = _export("BehaviorProperty", (function () { function BehaviorProperty(name, changeHandler, attribute, defaultValue, defaultBindingMode) { + _classCallCheck(this, BehaviorProperty); + this.name = name; this.changeHandler = changeHandler; this.attribute = attribute || hyphenate(name); @@ -69,10 +74,10 @@ System.register(["./util", "aurelia-binding"], function (_export) { Object.defineProperty(behavior.target.prototype, this.name, { configurable: true, enumerable: true, - get: function () { + get: function get() { return this.__observers__[that.name].getValue(); }, - set: function (value) { + set: function set(value) { this.__observers__[that.name].setValue(value); } }); @@ -83,6 +88,7 @@ System.register(["./util", "aurelia-binding"], function (_export) { createObserver: { value: function createObserver(executionContext) { var _this = this; + var selfSubscriber = null; if (this.changeHandler) { @@ -138,6 +144,8 @@ System.register(["./util", "aurelia-binding"], function (_export) { rest[_key - 1] = arguments[_key]; } + _classCallCheck(this, OptionsProperty); + if (typeof attribute === "string") { this.attribute = attribute; } else if (attribute) { @@ -249,8 +257,11 @@ System.register(["./util", "aurelia-binding"], function (_export) { return OptionsProperty; })(BehaviorProperty)); + BehaviorPropertyObserver = (function () { function BehaviorPropertyObserver(taskQueue, obj, propertyName, selfSubscriber) { + _classCallCheck(this, BehaviorPropertyObserver); + this.taskQueue = taskQueue; this.obj = obj; this.propertyName = propertyName; diff --git a/dist/system/resource-coordinator.js b/dist/system/resource-coordinator.js index 8d25de72..fa83f1fb 100644 --- a/dist/system/resource-coordinator.js +++ b/dist/system/resource-coordinator.js @@ -1,8 +1,5 @@ System.register(["aurelia-loader", "aurelia-path", "aurelia-dependency-injection", "aurelia-metadata", "aurelia-binding", "./custom-element", "./attached-behavior", "./template-controller", "./view-engine", "./resource-registry"], function (_export) { - "use strict"; - - var Loader, relativeToFile, join, Container, Metadata, ResourceType, Origin, ValueConverter, CustomElement, AttachedBehavior, TemplateController, ViewEngine, ResourceRegistry, _prototypeProperties, id, ResourceCoordinator, ResourceModule; - + var Loader, relativeToFile, join, Container, Metadata, ResourceType, Origin, ValueConverter, CustomElement, AttachedBehavior, TemplateController, ViewEngine, ResourceRegistry, _prototypeProperties, _classCallCheck, id, ResourceCoordinator, ResourceModule; function nextId() { return ++id; @@ -98,11 +95,17 @@ System.register(["aurelia-loader", "aurelia-path", "aurelia-dependency-injection ResourceRegistry = _resourceRegistry.ResourceRegistry; }], execute: function () { + "use strict"; + _prototypeProperties = function (child, staticProps, instanceProps) { if (staticProps) Object.defineProperties(child, staticProps); if (instanceProps) Object.defineProperties(child.prototype, instanceProps); }; + _classCallCheck = function (instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }; + id = 0; ResourceCoordinator = _export("ResourceCoordinator", (function () { function ResourceCoordinator(loader, container, viewEngine, appResources) { + _classCallCheck(this, ResourceCoordinator); + this.loader = loader; this.container = container; this.viewEngine = viewEngine; @@ -138,6 +141,7 @@ System.register(["aurelia-loader", "aurelia-path", "aurelia-dependency-injection loadElement: { value: function loadElement(moduleImport, moduleMember, viewStategy) { var _this = this; + return this._loadAndAnalyzeModuleForElement(moduleImport, moduleMember, this.importedModules, false).then(function (info) { var type = info.type; @@ -156,6 +160,7 @@ System.register(["aurelia-loader", "aurelia-path", "aurelia-dependency-injection _loadAndAnalyzeModuleForElement: { value: function _loadAndAnalyzeModuleForElement(moduleImport, moduleMember, cache, skipCacheLookup) { var _this = this; + var existing = !skipCacheLookup && cache[moduleImport]; if (existing) { @@ -251,6 +256,7 @@ System.register(["aurelia-loader", "aurelia-path", "aurelia-dependency-injection importResourcesFromModuleIds: { value: function importResourcesFromModuleIds(importIds) { var _this = this; + return this.loader.loadAllModules(importIds).then(function (imports) { return _this.importResourcesFromModules(imports, importIds); }); @@ -337,8 +343,11 @@ System.register(["aurelia-loader", "aurelia-path", "aurelia-dependency-injection return ResourceCoordinator; })()); + ResourceModule = (function () { function ResourceModule(source, element, resources) { + _classCallCheck(this, ResourceModule); + var i, ii, org; this.source = source; diff --git a/dist/system/resource-registry.js b/dist/system/resource-registry.js index 9c80dd14..d70fffa3 100644 --- a/dist/system/resource-registry.js +++ b/dist/system/resource-registry.js @@ -1,8 +1,5 @@ System.register(["aurelia-path"], function (_export) { - "use strict"; - - var relativeToFile, _get, _inherits, _prototypeProperties, ResourceRegistry, ViewResources; - + var relativeToFile, _get, _inherits, _prototypeProperties, _classCallCheck, ResourceRegistry, ViewResources; function register(lookup, name, resource, type) { if (!name) { @@ -26,14 +23,20 @@ System.register(["aurelia-path"], function (_export) { relativeToFile = _aureliaPath.relativeToFile; }], execute: function () { + "use strict"; + _get = function get(object, property, receiver) { var desc = Object.getOwnPropertyDescriptor(object, property); if (desc === undefined) { var parent = Object.getPrototypeOf(object); if (parent === null) { return undefined; } else { return get(parent, property, receiver); } } else if ("value" in desc && desc.writable) { return desc.value; } else { var getter = desc.get; if (getter === undefined) { return undefined; } return getter.call(receiver); } }; _inherits = function (subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) subClass.__proto__ = superClass; }; _prototypeProperties = function (child, staticProps, instanceProps) { if (staticProps) Object.defineProperties(child, staticProps); if (instanceProps) Object.defineProperties(child.prototype, instanceProps); }; + _classCallCheck = function (instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }; + ResourceRegistry = _export("ResourceRegistry", (function () { function ResourceRegistry() { + _classCallCheck(this, ResourceRegistry); + this.attributes = {}; this.elements = {}; this.valueConverters = {}; @@ -91,6 +94,8 @@ System.register(["aurelia-path"], function (_export) { })()); ViewResources = _export("ViewResources", (function (ResourceRegistry) { function ViewResources(parent, viewUrl) { + _classCallCheck(this, ViewResources); + _get(Object.getPrototypeOf(ViewResources.prototype), "constructor", this).call(this); this.parent = parent; this.viewUrl = viewUrl; diff --git a/dist/system/template-controller.js b/dist/system/template-controller.js index 137f2b8b..4058ee0e 100644 --- a/dist/system/template-controller.js +++ b/dist/system/template-controller.js @@ -1,7 +1,6 @@ System.register(["aurelia-metadata", "./behavior-instance", "./behaviors", "./util"], function (_export) { - "use strict"; + var ResourceType, BehaviorInstance, configureBehavior, hyphenate, _prototypeProperties, _inherits, _classCallCheck, TemplateController; - var ResourceType, BehaviorInstance, configureBehavior, hyphenate, _prototypeProperties, _inherits, TemplateController; return { setters: [function (_aureliaMetadata) { ResourceType = _aureliaMetadata.ResourceType; @@ -13,12 +12,18 @@ System.register(["aurelia-metadata", "./behavior-instance", "./behaviors", "./ut hyphenate = _util.hyphenate; }], execute: function () { + "use strict"; + _prototypeProperties = function (child, staticProps, instanceProps) { if (staticProps) Object.defineProperties(child, staticProps); if (instanceProps) Object.defineProperties(child.prototype, instanceProps); }; _inherits = function (subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) subClass.__proto__ = superClass; }; + _classCallCheck = function (instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }; + TemplateController = _export("TemplateController", (function (ResourceType) { function TemplateController(attribute) { + _classCallCheck(this, TemplateController); + this.name = attribute; this.properties = []; this.attributes = {}; @@ -70,8 +75,10 @@ System.register(["aurelia-metadata", "./behavior-instance", "./behaviors", "./ut if (node.parentNode) { node.parentNode.replaceChild(template, node); } else if (window.ShadowDOMPolyfill) { + //HACK: IE template element and shadow dom polyfills not quite right... ShadowDOMPolyfill.unwrap(parentNode).replaceChild(ShadowDOMPolyfill.unwrap(template), ShadowDOMPolyfill.unwrap(node)); } else { + //HACK: same as above parentNode.replaceChild(template, node); } diff --git a/dist/system/util.js b/dist/system/util.js index 492b6cf0..d89aa16f 100644 --- a/dist/system/util.js +++ b/dist/system/util.js @@ -1,7 +1,6 @@ System.register([], function (_export) { - "use strict"; - var capitalMatcher; + _export("hyphenate", hyphenate); function addHyphenAndLower(char) { @@ -11,9 +10,12 @@ System.register([], function (_export) { function hyphenate(name) { return (name.charAt(0).toLowerCase() + name.slice(1)).replace(capitalMatcher, addHyphenAndLower); } + return { setters: [], execute: function () { + "use strict"; + capitalMatcher = /([A-Z])/g; } }; diff --git a/dist/system/view-compiler.js b/dist/system/view-compiler.js index 0f5e1bc4..c12484a1 100644 --- a/dist/system/view-compiler.js +++ b/dist/system/view-compiler.js @@ -1,8 +1,5 @@ System.register(["./resource-registry", "./view-factory", "./binding-language"], function (_export) { - "use strict"; - - var ResourceRegistry, ViewFactory, BindingLanguage, _prototypeProperties, nextInjectorId, defaultCompileOptions, hasShadowDOM, ViewCompiler; - + var ResourceRegistry, ViewFactory, BindingLanguage, _prototypeProperties, _classCallCheck, nextInjectorId, defaultCompileOptions, hasShadowDOM, ViewCompiler; function getNextInjectorId() { return ++nextInjectorId; @@ -51,13 +48,19 @@ System.register(["./resource-registry", "./view-factory", "./binding-language"], BindingLanguage = _bindingLanguage.BindingLanguage; }], execute: function () { + "use strict"; + _prototypeProperties = function (child, staticProps, instanceProps) { if (staticProps) Object.defineProperties(child, staticProps); if (instanceProps) Object.defineProperties(child.prototype, instanceProps); }; + _classCallCheck = function (instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }; + nextInjectorId = 0; defaultCompileOptions = { targetShadowDOM: false }; hasShadowDOM = !!HTMLElement.prototype.createShadowRoot; ViewCompiler = _export("ViewCompiler", (function () { function ViewCompiler(bindingLanguage) { + _classCallCheck(this, ViewCompiler); + this.bindingLanguage = bindingLanguage; } @@ -73,6 +76,7 @@ System.register(["./resource-registry", "./view-factory", "./binding-language"], compile: { value: function compile(templateOrFragment, resources) { var options = arguments[2] === undefined ? defaultCompileOptions : arguments[2]; + var instructions = [], targetShadowDOM = options.targetShadowDOM, content; @@ -103,18 +107,21 @@ System.register(["./resource-registry", "./view-factory", "./binding-language"], value: function compileNode(node, resources, instructions, parentNode, parentInjectorId, targetLightDOM) { switch (node.nodeType) { case 1: + //element node return this.compileElement(node, resources, instructions, parentNode, parentInjectorId, targetLightDOM); case 3: + //text node var expression = this.bindingLanguage.parseText(resources, node.textContent); if (expression) { var marker = document.createElement("au-marker"); marker.className = "au-target"; - node.parentNode.insertBefore(marker, node); + (node.parentNode || parentNode).insertBefore(marker, node); node.textContent = " "; instructions.push({ contentExpression: expression }); } return node.nextSibling; case 11: + //document fragment node var currentChild = node.firstChild; while (currentChild) { currentChild = this.compileNode(currentChild, resources, instructions, node, parentInjectorId, targetLightDOM); @@ -180,25 +187,31 @@ System.register(["./resource-registry", "./view-factory", "./binding-language"], elementProperty = null; if (type) { - knownAttribute = resources.mapAttribute(info.attrName); + //do we have an attached behavior? + knownAttribute = resources.mapAttribute(info.attrName); //map the local name to real name if (knownAttribute) { property = type.attributes[knownAttribute]; if (property) { - info.defaultBindingMode = property.defaultBindingMode; + //if there's a defined property + info.defaultBindingMode = property.defaultBindingMode; //set the default binding mode if (!info.command && !info.expression) { - info.command = property.hasOptions ? "options" : null; + // if there is no command or detected expression + info.command = property.hasOptions ? "options" : null; //and it is an optons property, set the options command } } } } else if (elementInstruction) { + //or if this is on a custom element elementProperty = elementInstruction.type.attributes[info.attrName]; if (elementProperty) { - info.defaultBindingMode = elementProperty.defaultBindingMode; + //and this attribute is a custom property + info.defaultBindingMode = elementProperty.defaultBindingMode; //set the default binding mode if (!info.command && !info.expression) { - info.command = elementProperty.hasOptions ? "options" : null; + // if there is no command or detected expression + info.command = elementProperty.hasOptions ? "options" : null; //and it is an optons property, set the options command } } } @@ -210,45 +223,60 @@ System.register(["./resource-registry", "./view-factory", "./binding-language"], } if (instruction) { + //HAS BINDINGS if (instruction.alteredAttr) { type = resources.getAttribute(instruction.attrName); } if (instruction.discrete) { + //ref binding or listener binding expressions.push(instruction); } else { + //attribute bindings if (type) { + //templator or attached behavior found instruction.type = type; configureProperties(instruction, resources); if (type.liftsContent) { + //template controller instruction.originalAttrName = attrName; liftingInstruction = instruction; break; } else { + //attached behavior behaviorInstructions.push(instruction); } } else if (elementProperty) { + //custom element attribute elementInstruction.attributes[info.attrName].targetProperty = elementProperty.name; } else { + //standard attribute binding expressions.push(instruction.attributes[instruction.attrName]); } } } else { + //NO BINDINGS if (type) { + //templator or attached behavior found instruction = { attrName: attrName, type: type, attributes: {} }; instruction.attributes[resources.mapAttribute(attrName)] = attrValue; if (type.liftsContent) { + //template controller instruction.originalAttrName = attrName; liftingInstruction = instruction; break; } else { + //attached behavior behaviorInstructions.push(instruction); } } else if (elementProperty) { + //custom element attribute elementInstruction.attributes[attrName] = attrValue; } + + //else; normal attribute; do nothing } } diff --git a/dist/system/view-engine.js b/dist/system/view-engine.js index cf9a4875..e761044f 100644 --- a/dist/system/view-engine.js +++ b/dist/system/view-engine.js @@ -1,7 +1,6 @@ System.register(["aurelia-logging", "aurelia-loader", "aurelia-path", "./view-compiler", "./resource-registry"], function (_export) { - "use strict"; + var LogManager, Loader, relativeToFile, ViewCompiler, ResourceRegistry, ViewResources, _prototypeProperties, _classCallCheck, importSplitter, logger, ViewEngine; - var LogManager, Loader, relativeToFile, ViewCompiler, ResourceRegistry, ViewResources, _prototypeProperties, importSplitter, logger, ViewEngine; return { setters: [function (_aureliaLogging) { LogManager = _aureliaLogging; @@ -16,12 +15,18 @@ System.register(["aurelia-logging", "aurelia-loader", "aurelia-path", "./view-co ViewResources = _resourceRegistry.ViewResources; }], execute: function () { + "use strict"; + _prototypeProperties = function (child, staticProps, instanceProps) { if (staticProps) Object.defineProperties(child, staticProps); if (instanceProps) Object.defineProperties(child.prototype, instanceProps); }; + _classCallCheck = function (instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }; + importSplitter = /\s*,\s*/; logger = LogManager.getLogger("templating"); ViewEngine = _export("ViewEngine", (function () { function ViewEngine(loader, viewCompiler, appResources) { + _classCallCheck(this, ViewEngine); + this.loader = loader; this.viewCompiler = viewCompiler; this.appResources = appResources; @@ -40,6 +45,7 @@ System.register(["aurelia-logging", "aurelia-loader", "aurelia-path", "./view-co loadViewFactory: { value: function loadViewFactory(url, compileOptions, associatedModuleId) { var _this = this; + var existing = this.importedViews[url]; if (existing) { return Promise.resolve(existing); @@ -64,6 +70,7 @@ System.register(["aurelia-logging", "aurelia-loader", "aurelia-path", "./view-co loadTemplateResources: { value: function loadTemplateResources(templateUrl, template, associatedModuleId) { var _this = this; + var importIds, names, i, diff --git a/dist/system/view-factory.js b/dist/system/view-factory.js index 48703fe0..1ef43615 100644 --- a/dist/system/view-factory.js +++ b/dist/system/view-factory.js @@ -1,8 +1,5 @@ System.register(["aurelia-dependency-injection", "./view", "./view-slot", "./content-selector", "./resource-registry"], function (_export) { - "use strict"; - - var Container, View, ViewSlot, ContentSelector, ViewResources, _prototypeProperties, BoundViewFactory, defaultFactoryOptions, ViewFactory; - + var Container, View, ViewSlot, ContentSelector, ViewResources, _prototypeProperties, _classCallCheck, BoundViewFactory, defaultFactoryOptions, ViewFactory; function elementContainerGet(key) { if (key === Element) { @@ -106,10 +103,16 @@ System.register(["aurelia-dependency-injection", "./view", "./view-slot", "./con ViewResources = _resourceRegistry.ViewResources; }], execute: function () { + "use strict"; + _prototypeProperties = function (child, staticProps, instanceProps) { if (staticProps) Object.defineProperties(child, staticProps); if (instanceProps) Object.defineProperties(child.prototype, instanceProps); }; + _classCallCheck = function (instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }; + BoundViewFactory = _export("BoundViewFactory", (function () { function BoundViewFactory(parentContainer, viewFactory, executionContext) { + _classCallCheck(this, BoundViewFactory); + this.parentContainer = parentContainer; this.viewFactory = viewFactory; this.executionContext = executionContext; @@ -139,6 +142,8 @@ System.register(["aurelia-dependency-injection", "./view", "./view-slot", "./con }; ViewFactory = _export("ViewFactory", (function () { function ViewFactory(template, instructions, resources) { + _classCallCheck(this, ViewFactory); + this.template = template; this.instructions = instructions; this.resources = resources; @@ -148,6 +153,7 @@ System.register(["aurelia-dependency-injection", "./view", "./view-slot", "./con create: { value: function create(container, executionContext) { var options = arguments[2] === undefined ? defaultFactoryOptions : arguments[2]; + var fragment = this.template.cloneNode(true), instructables = fragment.querySelectorAll(".au-target"), instructions = this.instructions, diff --git a/dist/system/view-slot.js b/dist/system/view-slot.js index 3cca7371..6cd369e4 100644 --- a/dist/system/view-slot.js +++ b/dist/system/view-slot.js @@ -1,23 +1,32 @@ -System.register(["./content-selector"], function (_export) { - "use strict"; +System.register(["./content-selector", "./animator"], function (_export) { + var ContentSelector, Animator, _prototypeProperties, _classCallCheck, ViewSlot; - var ContentSelector, _prototypeProperties, ViewSlot; return { setters: [function (_contentSelector) { ContentSelector = _contentSelector.ContentSelector; + }, function (_animator) { + Animator = _animator.Animator; }], execute: function () { + "use strict"; + _prototypeProperties = function (child, staticProps, instanceProps) { if (staticProps) Object.defineProperties(child, staticProps); if (instanceProps) Object.defineProperties(child.prototype, instanceProps); }; + _classCallCheck = function (instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }; + ViewSlot = _export("ViewSlot", (function () { function ViewSlot(anchor, anchorIsContainer, executionContext) { + var animator = arguments[3] === undefined ? Animator.instance : arguments[3]; + + _classCallCheck(this, ViewSlot); + this.anchor = anchor; this.viewAddMethod = anchorIsContainer ? "appendNodesTo" : "insertNodesBefore"; this.executionContext = executionContext; + this.animator = animator; this.children = []; this.isBound = false; this.isAttached = false; - anchor.viewSlot = this; } @@ -27,6 +36,9 @@ System.register(["./content-selector"], function (_export) { var parent = this.anchor; this.children.push({ + fragment: parent, + firstChild: parent.firstChild, + lastChild: parent.lastChild, removeNodes: function removeNodes() { var last; @@ -88,6 +100,11 @@ System.register(["./content-selector"], function (_export) { if (this.isAttached) { view.attached(); + // Animate page itself + var element = view.firstChild.nextElementSibling; + if (view.firstChild.nodeType === 8 && element !== undefined && element.nodeType === 1 && element.classList.contains("au-animate")) { + this.animator.enter(element); + } } }, writable: true, @@ -112,6 +129,7 @@ System.register(["./content-selector"], function (_export) { remove: { value: function remove(view) { view.removeNodes(); + this.children.splice(this.children.indexOf(view), 1); if (this.isAttached) { @@ -123,45 +141,87 @@ System.register(["./content-selector"], function (_export) { }, removeAt: { value: function removeAt(index) { + var _this = this; + var view = this.children[index]; - view.removeNodes(); - this.children.splice(index, 1); + var removeAction = function () { + view.removeNodes(); + _this.children.splice(index, 1); - if (this.isAttached) { - view.detached(); - } + if (_this.isAttached) { + view.detached(); + } - return view; + return view; + }; + + var element = view.firstChild.nextElementSibling; + if (view.firstChild.nodeType === 8 && element !== undefined && element.nodeType === 1 && element.classList.contains("au-animate")) { + return this.animator.leave(element).then(function () { + return removeAction(); + }); + } else { + return removeAction(); + } }, writable: true, configurable: true }, removeAll: { value: function removeAll() { + var _this = this; + var children = this.children, ii = children.length, i; - for (i = 0; i < ii; ++i) { - children[i].removeNodes(); - } + var rmPromises = []; - if (this.isAttached) { - for (i = 0; i < ii; ++i) { - children[i].detached(); + children.forEach(function (child) { + var element = child.firstChild.nextElementSibling; + if (child.firstChild !== undefined && child.firstChild.nodeType === 8 && element !== undefined && element.nodeType === 1 && element.classList.contains("au-animate")) { + rmPromises.push(_this.animator.leave(element).then(function () { + child.removeNodes(); + })); + } else { + child.removeNodes(); } - } + }); - this.children = []; + var removeAction = function () { + if (_this.isAttached) { + for (i = 0; i < ii; ++i) { + children[i].detached(); + } + } + + _this.children = []; + }; + + if (rmPromises.length > 0) { + return Promise.all(rmPromises).then(function () { + removeAction(); + }); + } else { + removeAction(); + } }, writable: true, configurable: true }, swap: { value: function swap(view) { - this.removeAll(); - this.add(view); + var _this = this; + + var removeResponse = this.removeAll(); + if (removeResponse !== undefined) { + removeResponse.then(function () { + _this.add(view); + }); + } else { + this.add(view); + } }, writable: true, configurable: true @@ -179,6 +239,11 @@ System.register(["./content-selector"], function (_export) { children = this.children; for (i = 0, ii = children.length; i < ii; ++i) { children[i].attached(); + + var element = children[i].firstChild.nextElementSibling; + if (children[i].firstChild.nodeType === 8 && element !== undefined && element.nodeType === 1 && element.classList.contains("au-animate")) { + this.animator.enter(element); + } } }, writable: true, diff --git a/dist/system/view-strategy.js b/dist/system/view-strategy.js index 88a5002e..9d42f28f 100644 --- a/dist/system/view-strategy.js +++ b/dist/system/view-strategy.js @@ -1,7 +1,6 @@ System.register(["aurelia-metadata", "aurelia-path"], function (_export) { - "use strict"; + var Metadata, Origin, relativeToFile, _inherits, _prototypeProperties, _classCallCheck, ViewStrategy, UseView, ConventionalView, NoView; - var Metadata, Origin, relativeToFile, _inherits, _prototypeProperties, ViewStrategy, UseView, ConventionalView, NoView; return { setters: [function (_aureliaMetadata) { Metadata = _aureliaMetadata.Metadata; @@ -10,12 +9,18 @@ System.register(["aurelia-metadata", "aurelia-path"], function (_export) { relativeToFile = _aureliaPath.relativeToFile; }], execute: function () { + "use strict"; + _inherits = function (subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) subClass.__proto__ = superClass; }; _prototypeProperties = function (child, staticProps, instanceProps) { if (staticProps) Object.defineProperties(child, staticProps); if (instanceProps) Object.defineProperties(child.prototype, instanceProps); }; + _classCallCheck = function (instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }; + ViewStrategy = _export("ViewStrategy", (function () { - function ViewStrategy() {} + function ViewStrategy() { + _classCallCheck(this, ViewStrategy); + } _prototypeProperties(ViewStrategy, { normalize: { @@ -78,6 +83,8 @@ System.register(["aurelia-metadata", "aurelia-path"], function (_export) { })()); UseView = _export("UseView", (function (ViewStrategy) { function UseView(path) { + _classCallCheck(this, UseView); + this.path = path; } @@ -108,6 +115,8 @@ System.register(["aurelia-metadata", "aurelia-path"], function (_export) { })(ViewStrategy)); ConventionalView = _export("ConventionalView", (function (ViewStrategy) { function ConventionalView(moduleId) { + _classCallCheck(this, ConventionalView); + this.moduleId = moduleId; this.viewUrl = ConventionalView.convertModuleIdToViewUrl(moduleId); } @@ -136,8 +145,10 @@ System.register(["aurelia-metadata", "aurelia-path"], function (_export) { })(ViewStrategy)); NoView = _export("NoView", (function (ViewStrategy) { function NoView() { - if (Object.getPrototypeOf(NoView) !== null) { - Object.getPrototypeOf(NoView).apply(this, arguments); + _classCallCheck(this, NoView); + + if (ViewStrategy != null) { + ViewStrategy.apply(this, arguments); } } diff --git a/dist/system/view.js b/dist/system/view.js index e3c8d7b4..a3889e83 100644 --- a/dist/system/view.js +++ b/dist/system/view.js @@ -1,14 +1,22 @@ System.register([], function (_export) { - "use strict"; + var _prototypeProperties, _classCallCheck, View; - var _prototypeProperties, View; return { setters: [], execute: function () { + "use strict"; + _prototypeProperties = function (child, staticProps, instanceProps) { if (staticProps) Object.defineProperties(child, staticProps); if (instanceProps) Object.defineProperties(child.prototype, instanceProps); }; + _classCallCheck = function (instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }; + + //NOTE: Adding a fragment to the document causes the nodes to be removed from the fragment. + //NOTE: Adding to the fragment, causes the nodes to be removed from the document. + View = _export("View", (function () { function View(fragment, behaviors, bindings, children, systemControlled, contentSelectors) { + _classCallCheck(this, View); + this.fragment = fragment; this.behaviors = behaviors; this.bindings = bindings; diff --git a/doc/CHANGELOG.md b/doc/CHANGELOG.md index eca1855b..25fc6fb8 100644 --- a/doc/CHANGELOG.md +++ b/doc/CHANGELOG.md @@ -1,3 +1,25 @@ +### 0.8.13 (2015-02-28) + + +#### Bug Fixes + +* **anim:** + * local variable instead dereferencing ([2c033daf](http://github.com/aurelia/templating/commit/2c033daf4efd0f69af6572af64543763f08c8a24)) + * Only call animations if anim-class set ([8bf15dce](http://github.com/aurelia/templating/commit/8bf15dce0ed83834c4fecf8d61ff53fefe60b077)) + * Opt-In Animator ([02d83dd7](http://github.com/aurelia/templating/commit/02d83dd78126d45e2966aecf6a8bb8dcfc245314)) + * element enter fix ([172428e3](http://github.com/aurelia/templating/commit/172428e3f942f7e9c61e7afb9efb9729fbeef460)) +* **package:** update dependencies ([4a3489f9](http://github.com/aurelia/templating/commit/4a3489f983b75f194f38b0142fd4fe2ee3680184)) +* **view-slot:** + * transformChildNodesIntoView broken with animation ([03b94433](http://github.com/aurelia/templating/commit/03b94433bccf81ef5595d0495b4ba257ffb662ad)) + * prepare for animator implementation ([f922a86f](http://github.com/aurelia/templating/commit/f922a86feb4f42e34ca37650e0533dd75e9d17dc)) + + +#### Features + +* **Behaviour:** make UK devs jump for joy ([b5cc76c4](http://github.com/aurelia/templating/commit/b5cc76c4f5ce2aa985244d0bfd8248c71e305984), closes [#18](http://github.com/aurelia/templating/issues/18)) +* **anim:** Add animator service ([5d2d6169](http://github.com/aurelia/templating/commit/5d2d616988f723a3c20f06c2ae51ffe8f757c307)) + + ### 0.8.12 (2015-02-18) diff --git a/package.json b/package.json index 4ad92d46..624e09ea 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "aurelia-templating", - "version": "0.8.12", + "version": "0.8.13", "description": "An extensible HTML templating engine supporting databinding, custom elements, attached behaviors and more.", "keywords": [ "aurelia",