mirror of
https://github.com/esiur/iui.git
synced 2025-05-06 06:42:58 +00:00
scope fix
This commit is contained in:
parent
6a1fc15fad
commit
1db18defea
@ -162,6 +162,8 @@ export class IUI {
|
|||||||
|
|
||||||
if (scope == null)
|
if (scope == null)
|
||||||
scope = {};
|
scope = {};
|
||||||
|
else
|
||||||
|
scope = {...scope};
|
||||||
|
|
||||||
// get refs before they get overwritten
|
// get refs before they get overwritten
|
||||||
//let refs = scope?.refs;
|
//let refs = scope?.refs;
|
||||||
@ -169,7 +171,8 @@ export class IUI {
|
|||||||
// some element extended or overwritten the binding arguments
|
// some element extended or overwritten the binding arguments
|
||||||
if (element.scope != null)
|
if (element.scope != null)
|
||||||
IUI.extend(scope, element.scope, true);
|
IUI.extend(scope, element.scope, true);
|
||||||
else if (element.hasAttribute(":scope"))
|
|
||||||
|
if (element.hasAttribute(":scope"))
|
||||||
{
|
{
|
||||||
let script = element.getAttribute(":scope");
|
let script = element.getAttribute(":scope");
|
||||||
let code = `try {\r\n context.value = ${script}; \r\n}\r\n catch(ex) { context.error = ex; }`
|
let code = `try {\r\n context.value = ${script}; \r\n}\r\n catch(ex) { context.error = ex; }`
|
||||||
@ -281,8 +284,7 @@ export class IUI {
|
|||||||
|
|
||||||
let rt = func.apply(el.parentElement, scopeValues);
|
let rt = func.apply(el.parentElement, scopeValues);
|
||||||
|
|
||||||
console.log("rt", rt);
|
// Apply the returned object to the parent element.
|
||||||
|
|
||||||
if (typeof (rt) === "object") {
|
if (typeof (rt) === "object") {
|
||||||
for (var k in rt)
|
for (var k in rt)
|
||||||
el.parentElement[k] = rt[k];
|
el.parentElement[k] = rt[k];
|
||||||
|
@ -43,6 +43,7 @@ export default class IUIElement extends HTMLElement {
|
|||||||
await IUI.render(this, this._data);
|
await IUI.render(this, this._data);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
_getParentData() {
|
_getParentData() {
|
||||||
var p = this.parentElement;
|
var p = this.parentElement;
|
||||||
do {
|
do {
|
||||||
@ -58,8 +59,14 @@ export default class IUIElement extends HTMLElement {
|
|||||||
this._emit("data", {data: value});
|
this._emit("data", {data: value});
|
||||||
await IUI.render(this, value);
|
await IUI.render(this, value);
|
||||||
|
|
||||||
|
// notify updated callback
|
||||||
|
await this.updated();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
async updated() {
|
||||||
|
// to be implemented by the user.
|
||||||
|
}
|
||||||
|
|
||||||
get data() {
|
get data() {
|
||||||
return this._data;
|
return this._data;
|
||||||
|
@ -22,7 +22,7 @@ export default IUI.module(
|
|||||||
}
|
}
|
||||||
|
|
||||||
get scope() {
|
get scope() {
|
||||||
return { route: this, view: this };
|
return { route: this, view: this, refs: this.refs };
|
||||||
}
|
}
|
||||||
|
|
||||||
_updateLinks() {
|
_updateLinks() {
|
||||||
|
@ -62,5 +62,5 @@ window.addEventListener("load", async function () {
|
|||||||
});
|
});
|
||||||
|
|
||||||
window.iui = iui;
|
window.iui = iui;
|
||||||
|
window.IUI = IUI;
|
||||||
window.Modifiable = Modifiable;
|
window.Modifiable = Modifiable;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user