Skip to content

Commit

Permalink
chore(all): prepare release 0.13.3
Browse files Browse the repository at this point in the history
  • Loading branch information
EisenbergEffect committed Jul 13, 2015
1 parent a1fcdff commit a298096
Show file tree
Hide file tree
Showing 13 changed files with 794 additions and 35 deletions.
2 changes: 1 addition & 1 deletion bower.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "aurelia-templating",
"version": "0.13.2",
"version": "0.13.3",
"description": "An extensible HTML templating engine supporting databinding, custom elements, attached behaviors and more.",
"keywords": [
"aurelia",
Expand Down
5 changes: 3 additions & 2 deletions dist/amd/aurelia-templating.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ declare module 'aurelia-templating' {
// 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.
export class View {
constructor(fragment: any, behaviors: any, bindings: any, children: any, systemControlled: any, contentSelectors: any);
constructor(container: any, fragment: any, behaviors: any, bindings: any, children: any, systemControlled: any, contentSelectors: any);
created(executionContext: any): any;
bind(executionContext: any, systemUpdate: any): any;
addBinding(binding: any): any;
Expand Down Expand Up @@ -186,13 +186,14 @@ declare module 'aurelia-templating' {
}
export class ViewFactory {
constructor(template: any, instructions: any, resources: any);
create(container: any, executionContext: any, options?: any): any;
create(container: any, executionContext: any, options?: any, element?: any): any;
}
export class ViewCompiler {
static inject(): any;
constructor(bindingLanguage: any);
compile(templateOrFragment: any, resources: any, options?: any): any;
compileNode(node: any, resources: any, instructions: any, parentNode: any, parentInjectorId: any, targetLightDOM: any): any;
compileSurrogate(node: any, resources: any): any;
compileElement(node: any, resources: any, instructions: any, parentNode: any, parentInjectorId: any, targetLightDOM: any): any;
}
export class ViewEngine {
Expand Down
162 changes: 159 additions & 3 deletions dist/amd/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -393,9 +393,10 @@ define(['exports', 'core-js', 'aurelia-metadata', 'aurelia-path', 'aurelia-depen
exports.ViewResources = ViewResources;

var View = (function () {
function View(fragment, behaviors, bindings, children, systemControlled, contentSelectors) {
function View(container, fragment, behaviors, bindings, children, systemControlled, contentSelectors) {
_classCallCheck(this, View);

this.container = container;
this.fragment = fragment;
this.behaviors = behaviors;
this.bindings = bindings;
Expand Down Expand Up @@ -1145,6 +1146,43 @@ define(['exports', 'core-js', 'aurelia-metadata', 'aurelia-path', 'aurelia-depen
}
}

function applySurrogateInstruction(container, element, instruction, behaviors, bindings, children) {
var behaviorInstructions = instruction.behaviorInstructions,
expressions = instruction.expressions,
providers = instruction.providers,
values = instruction.values,
i = undefined,
ii = undefined,
current = undefined,
instance = undefined;

i = providers.length;
while (i--) {
container.registerSingleton(providers[i]);
}

for (var key in values) {
element.setAttribute(key, values[key]);
}

if (behaviorInstructions.length) {
for (i = 0, ii = behaviorInstructions.length; i < ii; ++i) {
current = behaviorInstructions[i];
instance = current.type.create(container, current, element, bindings, current.partReplacements);

if (instance.contentView) {
children.push(instance.contentView);
}

behaviors.push(instance);
}
}

for (i = 0, ii = expressions.length; i < ii; ++i) {
bindings.push(expressions[i].createBinding(element));
}
}

var BoundViewFactory = (function () {
function BoundViewFactory(parentContainer, viewFactory, executionContext) {
_classCallCheck(this, BoundViewFactory);
Expand Down Expand Up @@ -1185,6 +1223,7 @@ define(['exports', 'core-js', 'aurelia-metadata', 'aurelia-path', 'aurelia-depen

ViewFactory.prototype.create = function create(container, executionContext) {
var options = arguments[2] === undefined ? defaultFactoryOptions : arguments[2];
var element = arguments[3] === undefined ? null : arguments[3];

var fragment = this.template.cloneNode(true),
instructables = fragment.querySelectorAll('.au-target'),
Expand All @@ -1200,11 +1239,15 @@ define(['exports', 'core-js', 'aurelia-metadata', 'aurelia-path', 'aurelia-depen
ii,
view;

if (element !== null && this.surrogateInstruction !== null) {
applySurrogateInstruction(container, element, this.surrogateInstruction, behaviors, bindings, children);
}

for (i = 0, ii = instructables.length; i < ii; ++i) {
applyInstructions(containers, executionContext, instructables[i], instructions[i], behaviors, bindings, children, contentSelectors, partReplacements, resources);
}

view = new View(fragment, behaviors, bindings, children, options.systemControlled, contentSelectors);
view = new View(container, fragment, behaviors, bindings, children, options.systemControlled, contentSelectors);
view.created(executionContext);

if (!options.suppressBind) {
Expand Down Expand Up @@ -1316,6 +1359,7 @@ define(['exports', 'core-js', 'aurelia-metadata', 'aurelia-path', 'aurelia-depen
content.appendChild(document.createComment('</view>'));

var factory = new ViewFactory(content, instructions, resources);
factory.surrogateInstruction = templateOrFragment.content ? this.compileSurrogate(templateOrFragment, resources) : null;

if (part) {
factory.part = part;
Expand Down Expand Up @@ -1357,6 +1401,118 @@ define(['exports', 'core-js', 'aurelia-metadata', 'aurelia-path', 'aurelia-depen
return node.nextSibling;
};

ViewCompiler.prototype.compileSurrogate = function compileSurrogate(node, resources) {
var attributes = node.attributes,
bindingLanguage = this.bindingLanguage,
knownAttribute = undefined,
property = undefined,
instruction = undefined,
i = undefined,
ii = undefined,
attr = undefined,
attrName = undefined,
attrValue = undefined,
info = undefined,
type = undefined,
expressions = [],
expression = undefined,
behaviorInstructions = [],
values = {},
hasValues = false,
providers = [];

for (i = 0, ii = attributes.length; i < ii; ++i) {
attr = attributes[i];
attrName = attr.name;
attrValue = attr.value;

info = bindingLanguage.inspectAttribute(resources, attrName, attrValue);
type = resources.getAttribute(info.attrName);

if (type) {
knownAttribute = resources.mapAttribute(info.attrName);
if (knownAttribute) {
property = type.attributes[knownAttribute];

if (property) {
info.defaultBindingMode = property.defaultBindingMode;

if (!info.command && !info.expression) {
info.command = property.hasOptions ? 'options' : null;
}
}
}
}

instruction = bindingLanguage.createAttributeInstruction(resources, node, info);

if (instruction) {
if (instruction.alteredAttr) {
type = resources.getAttribute(instruction.attrName);
}

if (instruction.discrete) {
expressions.push(instruction);
} else {
if (type) {
instruction.type = type;
configureProperties(instruction, resources);

if (type.liftsContent) {
throw new Error('You cannot place a template controller on a surrogate element.');
} else {
behaviorInstructions.push(instruction);
}
} else {
expressions.push(instruction.attributes[instruction.attrName]);
}
}
} else {
if (type) {
instruction = { attrName: attrName, type: type, attributes: {} };
instruction.attributes[resources.mapAttribute(attrName)] = attrValue;

if (type.liftsContent) {
throw new Error('You cannot place a template controller on a surrogate element.');
} else {
behaviorInstructions.push(instruction);
}
} else if (attrName !== 'id' && attrName !== 'part' && attrName !== 'replace-part') {
hasValues = true;
values[attrName] = attrValue;
}
}
}

if (expressions.length || behaviorInstructions.length || hasValues) {
for (i = 0, ii = behaviorInstructions.length; i < ii; ++i) {
instruction = behaviorInstructions[i];
instruction.type.compile(this, resources, node, instruction);
providers.push(instruction.type.target);
}

for (i = 0, ii = expressions.length; i < ii; ++i) {
expression = expressions[i];
if (expression.attrToRemove !== undefined) {
node.removeAttribute(expression.attrToRemove);
}
}

return {
anchorIsContainer: false,
isCustomElement: false,
injectorId: null,
parentInjectorId: null,
expressions: expressions,
behaviorInstructions: behaviorInstructions,
providers: providers,
values: values
};
}

return null;
};

ViewCompiler.prototype.compileElement = function compileElement(node, resources, instructions, parentNode, parentInjectorId, targetLightDOM) {
var tagName = node.tagName.toLowerCase(),
attributes = node.attributes,
Expand Down Expand Up @@ -2313,7 +2469,7 @@ define(['exports', 'core-js', 'aurelia-metadata', 'aurelia-path', 'aurelia-depen
viewFactory = instruction.viewFactory || this.viewFactory;

if (viewFactory) {
behaviorInstance.view = viewFactory.create(container, executionContext, instruction);
behaviorInstance.view = viewFactory.create(container, executionContext, instruction, element);
}

if (element) {
Expand Down
5 changes: 3 additions & 2 deletions dist/commonjs/aurelia-templating.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ declare module 'aurelia-templating' {
// 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.
export class View {
constructor(fragment: any, behaviors: any, bindings: any, children: any, systemControlled: any, contentSelectors: any);
constructor(container: any, fragment: any, behaviors: any, bindings: any, children: any, systemControlled: any, contentSelectors: any);
created(executionContext: any): any;
bind(executionContext: any, systemUpdate: any): any;
addBinding(binding: any): any;
Expand Down Expand Up @@ -186,13 +186,14 @@ declare module 'aurelia-templating' {
}
export class ViewFactory {
constructor(template: any, instructions: any, resources: any);
create(container: any, executionContext: any, options?: any): any;
create(container: any, executionContext: any, options?: any, element?: any): any;
}
export class ViewCompiler {
static inject(): any;
constructor(bindingLanguage: any);
compile(templateOrFragment: any, resources: any, options?: any): any;
compileNode(node: any, resources: any, instructions: any, parentNode: any, parentInjectorId: any, targetLightDOM: any): any;
compileSurrogate(node: any, resources: any): any;
compileElement(node: any, resources: any, instructions: any, parentNode: any, parentInjectorId: any, targetLightDOM: any): any;
}
export class ViewEngine {
Expand Down
Loading

0 comments on commit a298096

Please sign in to comment.