2
0
mirror of https://github.com/esiur/iui.git synced 2025-05-06 06:42:58 +00:00
This commit is contained in:
Ahmed Zamil 2023-01-25 17:02:24 +03:00
parent 12627b1896
commit 90e9fb5c71
2 changed files with 25 additions and 8 deletions

View File

@ -200,7 +200,7 @@ export class IUI {
{
// copy attributes bindings
if (element.__i_bindings != null)
for(var i = 0; i < element.__i_bindings.length; i++)
for(let i = 0; i < element.__i_bindings.length; i++)
if (element.__i_bindings[i].type != BindingType.TextNode)
bindings.push(element.__i_bindings[i]);
}
@ -209,28 +209,41 @@ export class IUI {
element.__i_bindings?.destroy();
// compile attributes
for (var i = 0; i < element.attributes.length; i++) {
for (let i = 0; i < element.attributes.length; i++) {
let attr = element.attributes[i];
// skip scope
if (element.attributes[i].name == ":scope")
if (attr.name == ":scope")
continue;
if (element.attributes[i].name.startsWith("@")){
if (attr.name.startsWith("@")){
// make events
let code = element.attributes[i].value;
let code = attr.value;
//let code = `try {\r\n context.value = ${script}; \r\n}\r\n catch(ex) { context.error = ex; }`
let func = new Function("event", ...scopeArgs, code);
let handler = (event) => {
func.call(element, event, ...scopeValues);
}
bindings.addEvent(element.attributes[i].name.substr(1), handler);
bindings.addEvent(attr.name.substr(1), handler);
}
else if (attr.name.startsWith(":::"))
{
// make events
let code = attr.value;
//let code = `try {\r\n context.value = ${script}; \r\n}\r\n catch(ex) { context.error = ex; }`
let func = new Function("event", ...scopeArgs, code);
let handler = (event) => {
func.call(element, event, ...scopeValues);
}
bindings.addEvent(attr.name.substr(3), handler);
}
else
{
let b = Binding.create(element.attributes[i],
bindings.scope);
let b = Binding.create(attr, bindings.scope);
if (b != null) {
if (b.type == BindingType.HTMLElementDataAttribute

View File

@ -114,6 +114,10 @@ export default IUI.module(
}
async navigate(url, data, target, state, dataToQuery = true) {
if (url == null)
throw new Error("URL not specified.");
let q = url.match(/^\/*(.*?)\?(.*)$|^\/*(.*)$/);
var path;