@limetech/lime-web-components-testing
Advanced tools
Comparing version 4.51.2 to 4.51.8
@@ -6,2 +6,10 @@ # Change Log | ||
## [4.51.8](https://github.com/Lundalogik/lime-web-components/compare/v4.51.7...v4.51.8) (2022-08-01) | ||
**Note:** Version bump only for package @limetech/lime-web-components-testing | ||
## [4.51.2](https://github.com/Lundalogik/lime-web-components/compare/v4.51.1...v4.51.2) (2022-07-13) | ||
@@ -8,0 +16,0 @@ |
@@ -20,4 +20,2 @@ "use strict"; | ||
var componentProperties = new WeakMap(); | ||
var contexts = new WeakMap(); | ||
var contextObservables = new WeakMap(); | ||
var componentSubscriptions = new WeakMap(); | ||
@@ -45,3 +43,2 @@ var connectedComponents = new WeakMap(); | ||
component.componentWillLoad = createComponentWillLoad(component.componentWillLoad, properties); | ||
component.componentWillUpdate = createComponentWillUpdate(component.componentWillUpdate); | ||
component.componentDidUnload = createDisconnectedCallback(component.componentDidUnload); | ||
@@ -68,4 +65,3 @@ component.disconnectedCallback = createDisconnectedCallback(component.disconnectedCallback); | ||
observable = new rxjs_1.BehaviorSubject(this.context); | ||
contexts.set(this, this.context); | ||
contextObservables.set(this, observable); | ||
watchProp(this, 'context', observable); | ||
properties.forEach(function (property) { | ||
@@ -114,25 +110,2 @@ property.options = property.optionFactory(property.options, _this); | ||
} | ||
function createComponentWillUpdate(original) { | ||
return function () { | ||
var args = []; | ||
for (var _i = 0; _i < arguments.length; _i++) { | ||
args[_i] = arguments[_i]; | ||
} | ||
return tslib_1.__awaiter(this, void 0, void 0, function () { | ||
var context, observable; | ||
return tslib_1.__generator(this, function (_a) { | ||
context = contexts.get(this); | ||
if (context !== this.context) { | ||
contexts.set(this, this.context); | ||
observable = contextObservables.get(this); | ||
observable.next(this.context); | ||
} | ||
if (original) { | ||
return [2, original.apply(this, args)]; | ||
} | ||
return [2]; | ||
}); | ||
}); | ||
}; | ||
} | ||
function createDisconnectedCallback(original) { | ||
@@ -176,2 +149,3 @@ return function () { | ||
Object.defineProperty(element, property, { | ||
configurable: true, | ||
set: function (value) { | ||
@@ -185,2 +159,14 @@ delete element[property]; | ||
} | ||
function watchProp(target, property, observer) { | ||
var element = (0, core_1.getElement)(target); | ||
var _a = Object.getOwnPropertyDescriptor(Object.getPrototypeOf(element), property), get = _a.get, set = _a.set; | ||
Object.defineProperty(element, property, { | ||
configurable: true, | ||
get: get, | ||
set: function (value) { | ||
set.call(this, value); | ||
observer.next(value); | ||
}, | ||
}); | ||
} | ||
function subscribe(component, property) { | ||
@@ -187,0 +173,0 @@ var subscription = createSubscription(component, property); |
@@ -58,3 +58,3 @@ "use strict"; | ||
if (!hooks[name]) { | ||
hooks[name] = component[name]; | ||
hooks[name] = component[name] ? component[name] : function () { }; | ||
} | ||
@@ -67,5 +67,3 @@ component[name] = function () { | ||
hook.apply(this, args); | ||
if (hooks[name]) { | ||
return hooks[name].apply(this, args); | ||
} | ||
return hooks[name].apply(this, args); | ||
}; | ||
@@ -72,0 +70,0 @@ } |
@@ -22,4 +22,2 @@ import { getElement } from '@stencil/core'; | ||
const componentProperties = new WeakMap(); | ||
const contexts = new WeakMap(); | ||
const contextObservables = new WeakMap(); | ||
const componentSubscriptions = new WeakMap(); | ||
@@ -69,3 +67,2 @@ const connectedComponents = new WeakMap(); | ||
component.componentWillLoad = createComponentWillLoad(component.componentWillLoad, properties); | ||
component.componentWillUpdate = createComponentWillUpdate(component.componentWillUpdate); | ||
component.componentDidUnload = createDisconnectedCallback(component.componentDidUnload); | ||
@@ -80,4 +77,3 @@ component.disconnectedCallback = createDisconnectedCallback(component.disconnectedCallback); | ||
const observable = new BehaviorSubject(this.context); | ||
contexts.set(this, this.context); | ||
contextObservables.set(this, observable); | ||
watchProp(this, 'context', observable); | ||
properties.forEach((property) => { | ||
@@ -108,15 +104,2 @@ property.options = property.optionFactory(property.options, this); | ||
} | ||
function createComponentWillUpdate(original) { | ||
return async function (...args) { | ||
const context = contexts.get(this); | ||
if (context !== this.context) { | ||
contexts.set(this, this.context); | ||
const observable = contextObservables.get(this); | ||
observable.next(this.context); | ||
} | ||
if (original) { | ||
return original.apply(this, args); | ||
} | ||
}; | ||
} | ||
function createDisconnectedCallback(original) { | ||
@@ -171,2 +154,3 @@ return async function (...args) { | ||
Object.defineProperty(element, property, { | ||
configurable: true, | ||
set: (value) => { | ||
@@ -180,2 +164,14 @@ delete element[property]; | ||
} | ||
function watchProp(target, property, observer) { | ||
const element = getElement(target); | ||
const { get, set } = Object.getOwnPropertyDescriptor(Object.getPrototypeOf(element), property); | ||
Object.defineProperty(element, property, { | ||
configurable: true, | ||
get: get, | ||
set: function (value) { | ||
set.call(this, value); | ||
observer.next(value); | ||
}, | ||
}); | ||
} | ||
/** | ||
@@ -182,0 +178,0 @@ * Subscribe to changes from the state |
@@ -90,9 +90,7 @@ import { getElement } from '@stencil/core'; | ||
if (!hooks[name]) { | ||
hooks[name] = component[name]; | ||
hooks[name] = component[name] ? component[name] : function () { }; | ||
} | ||
component[name] = function (...args) { | ||
hook.apply(this, args); | ||
if (hooks[name]) { | ||
return hooks[name].apply(this, args); | ||
} | ||
return hooks[name].apply(this, args); | ||
}; | ||
@@ -99,0 +97,0 @@ } |
{ | ||
"name": "@limetech/lime-web-components-testing", | ||
"version": "4.51.2", | ||
"version": "4.51.8", | ||
"author": "Lime Technologies", | ||
@@ -37,3 +37,3 @@ "homepage": "https://github.com/Lundalogik/lime-web-components", | ||
"devDependencies": { | ||
"@stencil/core": "^2.17.1", | ||
"@stencil/core": "^2.17.2", | ||
"@types/jest": "^27.5.0", | ||
@@ -43,3 +43,3 @@ "jest": "^27.5.1", | ||
}, | ||
"gitHead": "6143edf98b30c999d658abab6db3fb6ac0268e8f" | ||
"gitHead": "07ceb59610d89da5688bf25fe44c5eb88cf717a3" | ||
} |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
917314
31097