mirror of
https://github.com/esiur/iui.git
synced 2025-05-06 06:42:58 +00:00
nav
This commit is contained in:
parent
12627b1896
commit
90e9fb5c71
@ -200,7 +200,7 @@ export class IUI {
|
|||||||
{
|
{
|
||||||
// copy attributes bindings
|
// copy attributes bindings
|
||||||
if (element.__i_bindings != null)
|
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)
|
if (element.__i_bindings[i].type != BindingType.TextNode)
|
||||||
bindings.push(element.__i_bindings[i]);
|
bindings.push(element.__i_bindings[i]);
|
||||||
}
|
}
|
||||||
@ -209,28 +209,41 @@ export class IUI {
|
|||||||
element.__i_bindings?.destroy();
|
element.__i_bindings?.destroy();
|
||||||
|
|
||||||
// compile attributes
|
// 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
|
// skip scope
|
||||||
if (element.attributes[i].name == ":scope")
|
if (attr.name == ":scope")
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (element.attributes[i].name.startsWith("@")){
|
if (attr.name.startsWith("@")){
|
||||||
|
|
||||||
// make events
|
// 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 code = `try {\r\n context.value = ${script}; \r\n}\r\n catch(ex) { context.error = ex; }`
|
||||||
let func = new Function("event", ...scopeArgs, code);
|
let func = new Function("event", ...scopeArgs, code);
|
||||||
let handler = (event) => {
|
let handler = (event) => {
|
||||||
func.call(element, event, ...scopeValues);
|
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
|
else
|
||||||
{
|
{
|
||||||
let b = Binding.create(element.attributes[i],
|
let b = Binding.create(attr, bindings.scope);
|
||||||
bindings.scope);
|
|
||||||
|
|
||||||
if (b != null) {
|
if (b != null) {
|
||||||
if (b.type == BindingType.HTMLElementDataAttribute
|
if (b.type == BindingType.HTMLElementDataAttribute
|
||||||
|
@ -114,6 +114,10 @@ export default IUI.module(
|
|||||||
}
|
}
|
||||||
|
|
||||||
async navigate(url, data, target, state, dataToQuery = true) {
|
async navigate(url, data, target, state, dataToQuery = true) {
|
||||||
|
|
||||||
|
if (url == null)
|
||||||
|
throw new Error("URL not specified.");
|
||||||
|
|
||||||
let q = url.match(/^\/*(.*?)\?(.*)$|^\/*(.*)$/);
|
let q = url.match(/^\/*(.*?)\?(.*)$|^\/*(.*)$/);
|
||||||
|
|
||||||
var path;
|
var path;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user