Skip to content

Commit

Permalink
chore: release 2.4.1
Browse files Browse the repository at this point in the history
Signed-off-by: Christian Kotzbauer <[email protected]>
  • Loading branch information
ckotzbauer committed Dec 5, 2020
1 parent 4deddf1 commit eebfe8a
Show file tree
Hide file tree
Showing 9 changed files with 143 additions and 32 deletions.
26 changes: 21 additions & 5 deletions dist/amd/knockout-composition.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,23 @@ define(["require", "exports", "knockout", "aurelia-dependency-injection", "aurel
}
return null;
}
function getAuTarget(elements) {
var _a;
for (var i = 0; i < elements.length; i++) {
if ((_a = elements.item(i)) === null || _a === void 0 ? void 0 : _a.classList.contains("au-target")) {
return elements.item(i);
}
}
return null;
}
function callEvent(element, eventName, args) {
var viewModel = ko.dataFor(element.children[0]);
var func = viewModel[eventName];
if (func && typeof func === 'function') {
func.apply(viewModel, args);
var target = getAuTarget(element.children);
if (target) {
var viewModel = ko.dataFor(target);
var func = viewModel[eventName];
if (func && typeof func === 'function') {
func.apply(viewModel, args);
}
}
}
function doComposition(element, unwrappedValue, viewModel) {
Expand Down Expand Up @@ -70,7 +82,7 @@ define(["require", "exports", "knockout", "aurelia-dependency-injection", "aurel
window.ko = ko;
}
ko.bindingHandlers.compose = {
update: function (element, valueAccessor, allBindings, viewModel) {
update: function (element, valueAccessor, allBindings, viewModel, bindingContext) {
var value = valueAccessor();
if (element.childElementCount > 0) {
// Remove previous composed view
Expand All @@ -79,6 +91,10 @@ define(["require", "exports", "knockout", "aurelia-dependency-injection", "aurel
element.removeChild(element.firstChild);
}
}
if (viewModel) {
viewModel.$parent = viewModel.$parent || bindingContext.$parent;
viewModel.$root = viewModel.$root || bindingContext.$root;
}
doComposition.call(_this, element, ko.unwrap(value), viewModel);
}
};
Expand Down
26 changes: 21 additions & 5 deletions dist/commonjs/knockout-composition.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,23 @@ function getMatchingProperty(result, propName) {
}
return null;
}
function getAuTarget(elements) {
var _a;
for (var i = 0; i < elements.length; i++) {
if ((_a = elements.item(i)) === null || _a === void 0 ? void 0 : _a.classList.contains("au-target")) {
return elements.item(i);
}
}
return null;
}
function callEvent(element, eventName, args) {
var viewModel = ko.dataFor(element.children[0]);
var func = viewModel[eventName];
if (func && typeof func === 'function') {
func.apply(viewModel, args);
var target = getAuTarget(element.children);
if (target) {
var viewModel = ko.dataFor(target);
var func = viewModel[eventName];
if (func && typeof func === 'function') {
func.apply(viewModel, args);
}
}
}
function doComposition(element, unwrappedValue, viewModel) {
Expand Down Expand Up @@ -73,7 +85,7 @@ var KnockoutComposition = /** @class */ (function () {
window.ko = ko;
}
ko.bindingHandlers.compose = {
update: function (element, valueAccessor, allBindings, viewModel) {
update: function (element, valueAccessor, allBindings, viewModel, bindingContext) {
var value = valueAccessor();
if (element.childElementCount > 0) {
// Remove previous composed view
Expand All @@ -82,6 +94,10 @@ var KnockoutComposition = /** @class */ (function () {
element.removeChild(element.firstChild);
}
}
if (viewModel) {
viewModel.$parent = viewModel.$parent || bindingContext.$parent;
viewModel.$root = viewModel.$root || bindingContext.$root;
}
doComposition.call(_this, element, ko.unwrap(value), viewModel);
}
};
Expand Down
26 changes: 21 additions & 5 deletions dist/es2015/knockout-composition.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,23 @@ function getMatchingProperty(result, propName) {
}
return null;
}
function getAuTarget(elements) {
var _a;
for (let i = 0; i < elements.length; i++) {
if ((_a = elements.item(i)) === null || _a === void 0 ? void 0 : _a.classList.contains("au-target")) {
return elements.item(i);
}
}
return null;
}
function callEvent(element, eventName, args) {
const viewModel = ko.dataFor(element.children[0]);
const func = viewModel[eventName];
if (func && typeof func === 'function') {
func.apply(viewModel, args);
const target = getAuTarget(element.children);
if (target) {
const viewModel = ko.dataFor(target);
const func = viewModel[eventName];
if (func && typeof func === 'function') {
func.apply(viewModel, args);
}
}
}
function doComposition(element, unwrappedValue, viewModel) {
Expand Down Expand Up @@ -68,7 +80,7 @@ let KnockoutComposition = class KnockoutComposition {
window.ko = ko;
}
ko.bindingHandlers.compose = {
update: (element, valueAccessor, allBindings, viewModel) => {
update: (element, valueAccessor, allBindings, viewModel, bindingContext) => {
const value = valueAccessor();
if (element.childElementCount > 0) {
// Remove previous composed view
Expand All @@ -77,6 +89,10 @@ let KnockoutComposition = class KnockoutComposition {
element.removeChild(element.firstChild);
}
}
if (viewModel) {
viewModel.$parent = viewModel.$parent || bindingContext.$parent;
viewModel.$root = viewModel.$root || bindingContext.$root;
}
doComposition.call(this, element, ko.unwrap(value), viewModel);
}
};
Expand Down
26 changes: 21 additions & 5 deletions dist/es2017/knockout-composition.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,23 @@ function getMatchingProperty(result, propName) {
}
return null;
}
function getAuTarget(elements) {
var _a;
for (let i = 0; i < elements.length; i++) {
if ((_a = elements.item(i)) === null || _a === void 0 ? void 0 : _a.classList.contains("au-target")) {
return elements.item(i);
}
}
return null;
}
function callEvent(element, eventName, args) {
const viewModel = ko.dataFor(element.children[0]);
const func = viewModel[eventName];
if (func && typeof func === 'function') {
func.apply(viewModel, args);
const target = getAuTarget(element.children);
if (target) {
const viewModel = ko.dataFor(target);
const func = viewModel[eventName];
if (func && typeof func === 'function') {
func.apply(viewModel, args);
}
}
}
function doComposition(element, unwrappedValue, viewModel) {
Expand Down Expand Up @@ -68,7 +80,7 @@ let KnockoutComposition = class KnockoutComposition {
window.ko = ko;
}
ko.bindingHandlers.compose = {
update: (element, valueAccessor, allBindings, viewModel) => {
update: (element, valueAccessor, allBindings, viewModel, bindingContext) => {
const value = valueAccessor();
if (element.childElementCount > 0) {
// Remove previous composed view
Expand All @@ -77,6 +89,10 @@ let KnockoutComposition = class KnockoutComposition {
element.removeChild(element.firstChild);
}
}
if (viewModel) {
viewModel.$parent = viewModel.$parent || bindingContext.$parent;
viewModel.$root = viewModel.$root || bindingContext.$root;
}
doComposition.call(this, element, ko.unwrap(value), viewModel);
}
};
Expand Down
26 changes: 21 additions & 5 deletions dist/native-modules/knockout-composition.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,23 @@ function getMatchingProperty(result, propName) {
}
return null;
}
function getAuTarget(elements) {
var _a;
for (var i = 0; i < elements.length; i++) {
if ((_a = elements.item(i)) === null || _a === void 0 ? void 0 : _a.classList.contains("au-target")) {
return elements.item(i);
}
}
return null;
}
function callEvent(element, eventName, args) {
var viewModel = ko.dataFor(element.children[0]);
var func = viewModel[eventName];
if (func && typeof func === 'function') {
func.apply(viewModel, args);
var target = getAuTarget(element.children);
if (target) {
var viewModel = ko.dataFor(target);
var func = viewModel[eventName];
if (func && typeof func === 'function') {
func.apply(viewModel, args);
}
}
}
function doComposition(element, unwrappedValue, viewModel) {
Expand Down Expand Up @@ -71,7 +83,7 @@ var KnockoutComposition = /** @class */ (function () {
window.ko = ko;
}
ko.bindingHandlers.compose = {
update: function (element, valueAccessor, allBindings, viewModel) {
update: function (element, valueAccessor, allBindings, viewModel, bindingContext) {
var value = valueAccessor();
if (element.childElementCount > 0) {
// Remove previous composed view
Expand All @@ -80,6 +92,10 @@ var KnockoutComposition = /** @class */ (function () {
element.removeChild(element.firstChild);
}
}
if (viewModel) {
viewModel.$parent = viewModel.$parent || bindingContext.$parent;
viewModel.$root = viewModel.$root || bindingContext.$root;
}
doComposition.call(_this, element, ko.unwrap(value), viewModel);
}
};
Expand Down
26 changes: 21 additions & 5 deletions dist/system/knockout-composition.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,23 @@ System.register(["knockout", "aurelia-dependency-injection", "aurelia-loader", "
}
return null;
}
function getAuTarget(elements) {
var _a;
for (var i = 0; i < elements.length; i++) {
if ((_a = elements.item(i)) === null || _a === void 0 ? void 0 : _a.classList.contains("au-target")) {
return elements.item(i);
}
}
return null;
}
function callEvent(element, eventName, args) {
var viewModel = ko.dataFor(element.children[0]);
var func = viewModel[eventName];
if (func && typeof func === 'function') {
func.apply(viewModel, args);
var target = getAuTarget(element.children);
if (target) {
var viewModel = ko.dataFor(target);
var func = viewModel[eventName];
if (func && typeof func === 'function') {
func.apply(viewModel, args);
}
}
}
function doComposition(element, unwrappedValue, viewModel) {
Expand Down Expand Up @@ -87,7 +99,7 @@ System.register(["knockout", "aurelia-dependency-injection", "aurelia-loader", "
window.ko = ko;
}
ko.bindingHandlers.compose = {
update: function (element, valueAccessor, allBindings, viewModel) {
update: function (element, valueAccessor, allBindings, viewModel, bindingContext) {
var value = valueAccessor();
if (element.childElementCount > 0) {
// Remove previous composed view
Expand All @@ -96,6 +108,10 @@ System.register(["knockout", "aurelia-dependency-injection", "aurelia-loader", "
element.removeChild(element.firstChild);
}
}
if (viewModel) {
viewModel.$parent = viewModel.$parent || bindingContext.$parent;
viewModel.$root = viewModel.$root || bindingContext.$root;
}
doComposition.call(_this, element, ko.unwrap(value), viewModel);
}
};
Expand Down
15 changes: 15 additions & 0 deletions doc/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,20 @@
# Changelog

## Version 2.4.1

Released on December 5, 2020.

- Fix: Preserve `$root` and `$parent` context when composing with `with` directive.
- Fix: Use first bound element to fetch view-model from.


## Version 2.4.0

Released on February 23, 2020.

- Updated dependencies


## Version 2.3.0

Released on July 27, 2018.
Expand Down
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "aurelia-knockout",
"version": "2.4.0",
"version": "2.4.1",
"main": "dist/commonjs/aurelia-knockout.js",
"author": "Christian Kotzbauer <[email protected]> (Twitter: https://twitter.com/ckotzbauer1)",
"license": "MIT",
Expand Down

0 comments on commit eebfe8a

Please sign in to comment.