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)
|
||||
scope = {};
|
||||
else
|
||||
scope = {...scope};
|
||||
|
||||
// get refs before they get overwritten
|
||||
//let refs = scope?.refs;
|
||||
@ -169,7 +171,8 @@ export class IUI {
|
||||
// some element extended or overwritten the binding arguments
|
||||
if (element.scope != null)
|
||||
IUI.extend(scope, element.scope, true);
|
||||
else if (element.hasAttribute(":scope"))
|
||||
|
||||
if (element.hasAttribute(":scope"))
|
||||
{
|
||||
let script = element.getAttribute(":scope");
|
||||
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);
|
||||
|
||||
console.log("rt", rt);
|
||||
|
||||
// Apply the returned object to the parent element.
|
||||
if (typeof (rt) === "object") {
|
||||
for (var k in rt)
|
||||
el.parentElement[k] = rt[k];
|
||||
|
@ -43,6 +43,7 @@ export default class IUIElement extends HTMLElement {
|
||||
await IUI.render(this, this._data);
|
||||
}
|
||||
|
||||
|
||||
_getParentData() {
|
||||
var p = this.parentElement;
|
||||
do {
|
||||
@ -58,9 +59,15 @@ export default class IUIElement extends HTMLElement {
|
||||
this._emit("data", {data: value});
|
||||
await IUI.render(this, value);
|
||||
|
||||
// notify updated callback
|
||||
await this.updated();
|
||||
}
|
||||
|
||||
|
||||
async updated() {
|
||||
// to be implemented by the user.
|
||||
}
|
||||
|
||||
get data() {
|
||||
return this._data;
|
||||
}
|
||||
|
@ -22,7 +22,7 @@ export default IUI.module(
|
||||
}
|
||||
|
||||
get scope() {
|
||||
return { route: this, view: this };
|
||||
return { route: this, view: this, refs: this.refs };
|
||||
}
|
||||
|
||||
_updateLinks() {
|
||||
|
@ -62,5 +62,5 @@ window.addEventListener("load", async function () {
|
||||
});
|
||||
|
||||
window.iui = iui;
|
||||
|
||||
window.IUI = IUI;
|
||||
window.Modifiable = Modifiable;
|
||||
|
Loading…
x
Reference in New Issue
Block a user