diff --git a/api/kweb-core.api b/api/kweb-core.api index 5813fbbf03..a966f007b1 100644 --- a/api/kweb-core.api +++ b/api/kweb-core.api @@ -195,9 +195,9 @@ public class kweb/ElementCreator { public final fun attr (Lkotlin/jvm/functions/Function1;)V public final fun cleanup ()V public final fun closeOnCleanup (Ljava/lang/AutoCloseable;)V - public final fun element (Ljava/lang/String;Ljava/util/Map;Ljava/lang/String;Lkotlin/jvm/functions/Function1;)Lkweb/Element; + public final fun element (Ljava/lang/String;Ljava/util/Map;Ljava/lang/String;Lkotlin/jvm/functions/Function2;)Lkweb/Element; public final fun element (Lkotlin/jvm/functions/Function1;)V - public static synthetic fun element$default (Lkweb/ElementCreator;Ljava/lang/String;Ljava/util/Map;Ljava/lang/String;Lkotlin/jvm/functions/Function1;ILjava/lang/Object;)Lkweb/Element; + public static synthetic fun element$default (Lkweb/ElementCreator;Ljava/lang/String;Ljava/util/Map;Ljava/lang/String;Lkotlin/jvm/functions/Function2;ILjava/lang/Object;)Lkweb/Element; public final fun getBrowser ()Lkweb/WebBrowser; public final fun getElement ()Lkweb/Element; public final fun getElementsCreatedCount ()I @@ -216,8 +216,8 @@ public final class kweb/ElementCreator$Companion : mu/KLogging { } public final class kweb/ElementKt { - public static final fun new (Lkweb/Element;Ljava/lang/String;Lkotlin/jvm/functions/Function1;)Ljava/lang/Object; - public static synthetic fun new$default (Lkweb/Element;Ljava/lang/String;Lkotlin/jvm/functions/Function1;ILjava/lang/Object;)Ljava/lang/Object; + public static final fun new (Lkweb/Element;Ljava/lang/String;Lkotlin/jvm/functions/Function2;)Ljava/lang/Object; + public static synthetic fun new$default (Lkweb/Element;Ljava/lang/String;Lkotlin/jvm/functions/Function2;ILjava/lang/Object;)Ljava/lang/Object; } public class kweb/FormElement : kweb/Element { @@ -365,89 +365,89 @@ public class kweb/PElement : kweb/Element { } public final class kweb/PreludeKt { - public static final fun a (Lkweb/ElementCreator;Ljava/util/Map;Ljava/lang/String;Lkotlin/jvm/functions/Function1;)Lkweb/AElement; - public static synthetic fun a$default (Lkweb/ElementCreator;Ljava/util/Map;Ljava/lang/String;Lkotlin/jvm/functions/Function1;ILjava/lang/Object;)Lkweb/AElement; + public static final fun a (Lkweb/ElementCreator;Ljava/util/Map;Ljava/lang/String;Lkotlin/jvm/functions/Function2;)Lkweb/AElement; + public static synthetic fun a$default (Lkweb/ElementCreator;Ljava/util/Map;Ljava/lang/String;Lkotlin/jvm/functions/Function2;ILjava/lang/Object;)Lkweb/AElement; public static final fun attr (Ljava/lang/String;Lkweb/state/KVar;)Lkweb/state/KVal; public static final fun attr (Lkweb/state/KVar;Ljava/lang/String;)Lkweb/state/KVal; - public static final fun br (Lkweb/ElementCreator;Ljava/util/Map;Lkotlin/jvm/functions/Function1;)Lkweb/BrElement; - public static synthetic fun br$default (Lkweb/ElementCreator;Ljava/util/Map;Lkotlin/jvm/functions/Function1;ILjava/lang/Object;)Lkweb/BrElement; - public static final fun button (Lkweb/ElementCreator;Ljava/util/Map;Lkweb/ButtonType;Ljava/lang/Boolean;Lkotlin/jvm/functions/Function1;)Lkweb/ButtonElement; - public static synthetic fun button$default (Lkweb/ElementCreator;Ljava/util/Map;Lkweb/ButtonType;Ljava/lang/Boolean;Lkotlin/jvm/functions/Function1;ILjava/lang/Object;)Lkweb/ButtonElement; - public static final fun canvas (Lkweb/ElementCreator;Ljava/util/Map;IILkotlin/jvm/functions/Function1;)Lkweb/CanvasElement; - public static synthetic fun canvas$default (Lkweb/ElementCreator;Ljava/util/Map;IILkotlin/jvm/functions/Function1;ILjava/lang/Object;)Lkweb/CanvasElement; - public static final fun div (Lkweb/ElementCreator;Ljava/util/Map;Lkotlin/jvm/functions/Function1;)Lkweb/DivElement; - public static synthetic fun div$default (Lkweb/ElementCreator;Ljava/util/Map;Lkotlin/jvm/functions/Function1;ILjava/lang/Object;)Lkweb/DivElement; + public static final fun br (Lkweb/ElementCreator;Ljava/util/Map;Lkotlin/jvm/functions/Function2;)Lkweb/BrElement; + public static synthetic fun br$default (Lkweb/ElementCreator;Ljava/util/Map;Lkotlin/jvm/functions/Function2;ILjava/lang/Object;)Lkweb/BrElement; + public static final fun button (Lkweb/ElementCreator;Ljava/util/Map;Lkweb/ButtonType;Ljava/lang/Boolean;Lkotlin/jvm/functions/Function2;)Lkweb/ButtonElement; + public static synthetic fun button$default (Lkweb/ElementCreator;Ljava/util/Map;Lkweb/ButtonType;Ljava/lang/Boolean;Lkotlin/jvm/functions/Function2;ILjava/lang/Object;)Lkweb/ButtonElement; + public static final fun canvas (Lkweb/ElementCreator;Ljava/util/Map;IILkotlin/jvm/functions/Function2;)Lkweb/CanvasElement; + public static synthetic fun canvas$default (Lkweb/ElementCreator;Ljava/util/Map;IILkotlin/jvm/functions/Function2;ILjava/lang/Object;)Lkweb/CanvasElement; + public static final fun div (Lkweb/ElementCreator;Ljava/util/Map;Lkotlin/jvm/functions/Function2;)Lkweb/DivElement; + public static synthetic fun div$default (Lkweb/ElementCreator;Ljava/util/Map;Lkotlin/jvm/functions/Function2;ILjava/lang/Object;)Lkweb/DivElement; public static final fun fileInput (Lkweb/ElementCreator;Ljava/lang/String;Ljava/lang/String;Ljava/lang/Integer;Ljava/lang/String;Ljava/util/Map;)Lkweb/html/fileUpload/FileFormInput; public static synthetic fun fileInput$default (Lkweb/ElementCreator;Ljava/lang/String;Ljava/lang/String;Ljava/lang/Integer;Ljava/lang/String;Ljava/util/Map;ILjava/lang/Object;)Lkweb/html/fileUpload/FileFormInput; - public static final fun form (Lkweb/ElementCreator;Ljava/util/Map;Lkotlin/jvm/functions/Function1;)Lkweb/FormElement; - public static synthetic fun form$default (Lkweb/ElementCreator;Ljava/util/Map;Lkotlin/jvm/functions/Function1;ILjava/lang/Object;)Lkweb/FormElement; + public static final fun form (Lkweb/ElementCreator;Ljava/util/Map;Lkotlin/jvm/functions/Function2;)Lkweb/FormElement; + public static synthetic fun form$default (Lkweb/ElementCreator;Ljava/util/Map;Lkotlin/jvm/functions/Function2;ILjava/lang/Object;)Lkweb/FormElement; public static final fun get (Lkweb/state/KVar;I)Lkweb/state/KVar; public static final fun get (Lkweb/state/KVar;Ljava/lang/Object;)Lkweb/state/KVar; public static final fun getPath (Lkweb/state/KVar;)Lkweb/state/KVar; public static final fun getPathQueryFragment (Lkweb/state/KVar;)Lkweb/state/KVar; public static final fun getPathSegments (Lkweb/state/KVar;)Lkweb/state/KVar; public static final fun getQuery (Lkweb/state/KVar;)Lkweb/state/KVar; - public static final fun h1 (Lkweb/ElementCreator;Ljava/util/Map;Lkotlin/jvm/functions/Function1;)Lkweb/H1Element; - public static synthetic fun h1$default (Lkweb/ElementCreator;Ljava/util/Map;Lkotlin/jvm/functions/Function1;ILjava/lang/Object;)Lkweb/H1Element; - public static final fun h2 (Lkweb/ElementCreator;Ljava/util/Map;Lkotlin/jvm/functions/Function1;)Lkweb/H2Element; - public static synthetic fun h2$default (Lkweb/ElementCreator;Ljava/util/Map;Lkotlin/jvm/functions/Function1;ILjava/lang/Object;)Lkweb/H2Element; - public static final fun h3 (Lkweb/ElementCreator;Ljava/util/Map;Lkotlin/jvm/functions/Function1;)Lkweb/H3Element; - public static synthetic fun h3$default (Lkweb/ElementCreator;Ljava/util/Map;Lkotlin/jvm/functions/Function1;ILjava/lang/Object;)Lkweb/H3Element; - public static final fun h4 (Lkweb/ElementCreator;Ljava/util/Map;Lkotlin/jvm/functions/Function1;)Lkweb/H4Element; - public static synthetic fun h4$default (Lkweb/ElementCreator;Ljava/util/Map;Lkotlin/jvm/functions/Function1;ILjava/lang/Object;)Lkweb/H4Element; - public static final fun h5 (Lkweb/ElementCreator;Ljava/util/Map;Lkotlin/jvm/functions/Function1;)Lkweb/H5Element; - public static synthetic fun h5$default (Lkweb/ElementCreator;Ljava/util/Map;Lkotlin/jvm/functions/Function1;ILjava/lang/Object;)Lkweb/H5Element; - public static final fun i (Lkweb/ElementCreator;Ljava/util/Map;Lkotlin/jvm/functions/Function1;)Lkweb/IElement; - public static synthetic fun i$default (Lkweb/ElementCreator;Ljava/util/Map;Lkotlin/jvm/functions/Function1;ILjava/lang/Object;)Lkweb/IElement; - public static final fun img (Lkweb/ElementCreator;Ljava/util/Map;Lkotlin/jvm/functions/Function1;)Lkweb/ImageElement; - public static synthetic fun img$default (Lkweb/ElementCreator;Ljava/util/Map;Lkotlin/jvm/functions/Function1;ILjava/lang/Object;)Lkweb/ImageElement; - public static final fun input (Lkweb/ElementCreator;Ljava/util/Map;Lkweb/InputType;Ljava/lang/String;Ljava/lang/String;Ljava/lang/Integer;Ljava/lang/String;Lkotlin/jvm/functions/Function1;)Lkweb/InputElement; - public static synthetic fun input$default (Lkweb/ElementCreator;Ljava/util/Map;Lkweb/InputType;Ljava/lang/String;Ljava/lang/String;Ljava/lang/Integer;Ljava/lang/String;Lkotlin/jvm/functions/Function1;ILjava/lang/Object;)Lkweb/InputElement; - public static final fun label (Lkweb/ElementCreator;Ljava/util/Map;Lkotlin/jvm/functions/Function1;)Lkweb/LabelElement; - public static synthetic fun label$default (Lkweb/ElementCreator;Ljava/util/Map;Lkotlin/jvm/functions/Function1;ILjava/lang/Object;)Lkweb/LabelElement; - public static final fun li (Lkweb/ElementCreator;Ljava/util/Map;Lkotlin/jvm/functions/Function1;)Lkweb/LIElement; - public static synthetic fun li$default (Lkweb/ElementCreator;Ljava/util/Map;Lkotlin/jvm/functions/Function1;ILjava/lang/Object;)Lkweb/LIElement; - public static final fun meta (Lkweb/ElementCreator;Ljava/util/Map;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Lkotlin/jvm/functions/Function1;)Lkweb/MetaElement; - public static synthetic fun meta$default (Lkweb/ElementCreator;Ljava/util/Map;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Lkotlin/jvm/functions/Function1;ILjava/lang/Object;)Lkweb/MetaElement; - public static final fun nav (Lkweb/ElementCreator;Ljava/util/Map;Lkotlin/jvm/functions/Function1;)Lkweb/NavElement; - public static synthetic fun nav$default (Lkweb/ElementCreator;Ljava/util/Map;Lkotlin/jvm/functions/Function1;ILjava/lang/Object;)Lkweb/NavElement; - public static final fun ol (Lkweb/ElementCreator;Ljava/util/Map;Lkotlin/jvm/functions/Function1;)Lkweb/OLElement; - public static synthetic fun ol$default (Lkweb/ElementCreator;Ljava/util/Map;Lkotlin/jvm/functions/Function1;ILjava/lang/Object;)Lkweb/OLElement; - public static final fun option (Lkweb/ElementCreator;Ljava/util/Map;Lkotlin/jvm/functions/Function1;)Lkweb/OptionElement; - public static synthetic fun option$default (Lkweb/ElementCreator;Ljava/util/Map;Lkotlin/jvm/functions/Function1;ILjava/lang/Object;)Lkweb/OptionElement; - public static final fun p (Lkweb/ElementCreator;Ljava/util/Map;Lkotlin/jvm/functions/Function1;)Lkweb/PElement; - public static synthetic fun p$default (Lkweb/ElementCreator;Ljava/util/Map;Lkotlin/jvm/functions/Function1;ILjava/lang/Object;)Lkweb/PElement; + public static final fun h1 (Lkweb/ElementCreator;Ljava/util/Map;Lkotlin/jvm/functions/Function2;)Lkweb/H1Element; + public static synthetic fun h1$default (Lkweb/ElementCreator;Ljava/util/Map;Lkotlin/jvm/functions/Function2;ILjava/lang/Object;)Lkweb/H1Element; + public static final fun h2 (Lkweb/ElementCreator;Ljava/util/Map;Lkotlin/jvm/functions/Function2;)Lkweb/H2Element; + public static synthetic fun h2$default (Lkweb/ElementCreator;Ljava/util/Map;Lkotlin/jvm/functions/Function2;ILjava/lang/Object;)Lkweb/H2Element; + public static final fun h3 (Lkweb/ElementCreator;Ljava/util/Map;Lkotlin/jvm/functions/Function2;)Lkweb/H3Element; + public static synthetic fun h3$default (Lkweb/ElementCreator;Ljava/util/Map;Lkotlin/jvm/functions/Function2;ILjava/lang/Object;)Lkweb/H3Element; + public static final fun h4 (Lkweb/ElementCreator;Ljava/util/Map;Lkotlin/jvm/functions/Function2;)Lkweb/H4Element; + public static synthetic fun h4$default (Lkweb/ElementCreator;Ljava/util/Map;Lkotlin/jvm/functions/Function2;ILjava/lang/Object;)Lkweb/H4Element; + public static final fun h5 (Lkweb/ElementCreator;Ljava/util/Map;Lkotlin/jvm/functions/Function2;)Lkweb/H5Element; + public static synthetic fun h5$default (Lkweb/ElementCreator;Ljava/util/Map;Lkotlin/jvm/functions/Function2;ILjava/lang/Object;)Lkweb/H5Element; + public static final fun i (Lkweb/ElementCreator;Ljava/util/Map;Lkotlin/jvm/functions/Function2;)Lkweb/IElement; + public static synthetic fun i$default (Lkweb/ElementCreator;Ljava/util/Map;Lkotlin/jvm/functions/Function2;ILjava/lang/Object;)Lkweb/IElement; + public static final fun img (Lkweb/ElementCreator;Ljava/util/Map;Lkotlin/jvm/functions/Function2;)Lkweb/ImageElement; + public static synthetic fun img$default (Lkweb/ElementCreator;Ljava/util/Map;Lkotlin/jvm/functions/Function2;ILjava/lang/Object;)Lkweb/ImageElement; + public static final fun input (Lkweb/ElementCreator;Ljava/util/Map;Lkweb/InputType;Ljava/lang/String;Ljava/lang/String;Ljava/lang/Integer;Ljava/lang/String;Lkotlin/jvm/functions/Function2;)Lkweb/InputElement; + public static synthetic fun input$default (Lkweb/ElementCreator;Ljava/util/Map;Lkweb/InputType;Ljava/lang/String;Ljava/lang/String;Ljava/lang/Integer;Ljava/lang/String;Lkotlin/jvm/functions/Function2;ILjava/lang/Object;)Lkweb/InputElement; + public static final fun label (Lkweb/ElementCreator;Ljava/util/Map;Lkotlin/jvm/functions/Function2;)Lkweb/LabelElement; + public static synthetic fun label$default (Lkweb/ElementCreator;Ljava/util/Map;Lkotlin/jvm/functions/Function2;ILjava/lang/Object;)Lkweb/LabelElement; + public static final fun li (Lkweb/ElementCreator;Ljava/util/Map;Lkotlin/jvm/functions/Function2;)Lkweb/LIElement; + public static synthetic fun li$default (Lkweb/ElementCreator;Ljava/util/Map;Lkotlin/jvm/functions/Function2;ILjava/lang/Object;)Lkweb/LIElement; + public static final fun meta (Lkweb/ElementCreator;Ljava/util/Map;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Lkotlin/jvm/functions/Function2;)Lkweb/MetaElement; + public static synthetic fun meta$default (Lkweb/ElementCreator;Ljava/util/Map;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Lkotlin/jvm/functions/Function2;ILjava/lang/Object;)Lkweb/MetaElement; + public static final fun nav (Lkweb/ElementCreator;Ljava/util/Map;Lkotlin/jvm/functions/Function2;)Lkweb/NavElement; + public static synthetic fun nav$default (Lkweb/ElementCreator;Ljava/util/Map;Lkotlin/jvm/functions/Function2;ILjava/lang/Object;)Lkweb/NavElement; + public static final fun ol (Lkweb/ElementCreator;Ljava/util/Map;Lkotlin/jvm/functions/Function2;)Lkweb/OLElement; + public static synthetic fun ol$default (Lkweb/ElementCreator;Ljava/util/Map;Lkotlin/jvm/functions/Function2;ILjava/lang/Object;)Lkweb/OLElement; + public static final fun option (Lkweb/ElementCreator;Ljava/util/Map;Lkotlin/jvm/functions/Function2;)Lkweb/OptionElement; + public static synthetic fun option$default (Lkweb/ElementCreator;Ljava/util/Map;Lkotlin/jvm/functions/Function2;ILjava/lang/Object;)Lkweb/OptionElement; + public static final fun p (Lkweb/ElementCreator;Ljava/util/Map;Lkotlin/jvm/functions/Function2;)Lkweb/PElement; + public static synthetic fun p$default (Lkweb/ElementCreator;Ljava/util/Map;Lkotlin/jvm/functions/Function2;ILjava/lang/Object;)Lkweb/PElement; public static final fun renderEach (Lkweb/ElementCreator;Lkweb/state/KVar;Lkotlin/jvm/functions/Function2;)V public static final fun route (Lkweb/ElementCreator;Lkotlin/jvm/functions/Function1;)V - public static final fun section (Lkweb/ElementCreator;Ljava/util/Map;Lkotlin/jvm/functions/Function1;)Lkweb/SectionElement; - public static synthetic fun section$default (Lkweb/ElementCreator;Ljava/util/Map;Lkotlin/jvm/functions/Function1;ILjava/lang/Object;)Lkweb/SectionElement; - public static final fun select (Lkweb/ElementCreator;Ljava/util/Map;Ljava/lang/String;Ljava/lang/Boolean;Lkotlin/jvm/functions/Function1;)Lkweb/SelectElement; - public static synthetic fun select$default (Lkweb/ElementCreator;Ljava/util/Map;Ljava/lang/String;Ljava/lang/Boolean;Lkotlin/jvm/functions/Function1;ILjava/lang/Object;)Lkweb/SelectElement; - public static final fun span (Lkweb/ElementCreator;Ljava/util/Map;Lkotlin/jvm/functions/Function1;)Lkweb/SpanElement; - public static synthetic fun span$default (Lkweb/ElementCreator;Ljava/util/Map;Lkotlin/jvm/functions/Function1;ILjava/lang/Object;)Lkweb/SpanElement; + public static final fun section (Lkweb/ElementCreator;Ljava/util/Map;Lkotlin/jvm/functions/Function2;)Lkweb/SectionElement; + public static synthetic fun section$default (Lkweb/ElementCreator;Ljava/util/Map;Lkotlin/jvm/functions/Function2;ILjava/lang/Object;)Lkweb/SectionElement; + public static final fun select (Lkweb/ElementCreator;Ljava/util/Map;Ljava/lang/String;Ljava/lang/Boolean;Lkotlin/jvm/functions/Function2;)Lkweb/SelectElement; + public static synthetic fun select$default (Lkweb/ElementCreator;Ljava/util/Map;Ljava/lang/String;Ljava/lang/Boolean;Lkotlin/jvm/functions/Function2;ILjava/lang/Object;)Lkweb/SelectElement; + public static final fun span (Lkweb/ElementCreator;Ljava/util/Map;Lkotlin/jvm/functions/Function2;)Lkweb/SpanElement; + public static synthetic fun span$default (Lkweb/ElementCreator;Ljava/util/Map;Lkotlin/jvm/functions/Function2;ILjava/lang/Object;)Lkweb/SpanElement; public static final fun subList (Lkweb/state/KVal;II)Lkweb/state/KVal; public static final fun subList (Lkweb/state/KVar;II)Lkweb/state/KVar; - public static final fun table (Lkweb/ElementCreator;Ljava/util/Map;Lkotlin/jvm/functions/Function1;)Lkweb/TableElement; - public static synthetic fun table$default (Lkweb/ElementCreator;Ljava/util/Map;Lkotlin/jvm/functions/Function1;ILjava/lang/Object;)Lkweb/TableElement; - public static final fun tbody (Lkweb/ElementCreator;Ljava/util/Map;Lkotlin/jvm/functions/Function1;)Lkweb/TbodyElement; - public static synthetic fun tbody$default (Lkweb/ElementCreator;Ljava/util/Map;Lkotlin/jvm/functions/Function1;ILjava/lang/Object;)Lkweb/TbodyElement; - public static final fun td (Lkweb/ElementCreator;Ljava/util/Map;Lkotlin/jvm/functions/Function1;)Lkweb/TdElement; - public static synthetic fun td$default (Lkweb/ElementCreator;Ljava/util/Map;Lkotlin/jvm/functions/Function1;ILjava/lang/Object;)Lkweb/TdElement; - public static final fun textArea (Lkweb/ElementCreator;Ljava/util/Map;Ljava/lang/Integer;Ljava/lang/Integer;Ljava/lang/Boolean;Lkotlin/jvm/functions/Function1;)Lkweb/TextAreaElement; - public static final fun textArea (Lkweb/ElementCreator;Ljava/util/Map;Lkotlin/jvm/functions/Function1;)Lkweb/TextAreaElement; - public static synthetic fun textArea$default (Lkweb/ElementCreator;Ljava/util/Map;Ljava/lang/Integer;Ljava/lang/Integer;Ljava/lang/Boolean;Lkotlin/jvm/functions/Function1;ILjava/lang/Object;)Lkweb/TextAreaElement; - public static synthetic fun textArea$default (Lkweb/ElementCreator;Ljava/util/Map;Lkotlin/jvm/functions/Function1;ILjava/lang/Object;)Lkweb/TextAreaElement; - public static final fun th (Lkweb/ElementCreator;Ljava/util/Map;Lkotlin/jvm/functions/Function1;)Lkweb/ThElement; - public static synthetic fun th$default (Lkweb/ElementCreator;Ljava/util/Map;Lkotlin/jvm/functions/Function1;ILjava/lang/Object;)Lkweb/ThElement; - public static final fun thead (Lkweb/ElementCreator;Ljava/util/Map;Lkotlin/jvm/functions/Function1;)Lkweb/TheadElement; - public static synthetic fun thead$default (Lkweb/ElementCreator;Ljava/util/Map;Lkotlin/jvm/functions/Function1;ILjava/lang/Object;)Lkweb/TheadElement; - public static final fun title (Lkweb/ElementCreator;Ljava/util/Map;Lkotlin/jvm/functions/Function1;)Lkweb/html/TitleElement; - public static synthetic fun title$default (Lkweb/ElementCreator;Ljava/util/Map;Lkotlin/jvm/functions/Function1;ILjava/lang/Object;)Lkweb/html/TitleElement; + public static final fun table (Lkweb/ElementCreator;Ljava/util/Map;Lkotlin/jvm/functions/Function2;)Lkweb/TableElement; + public static synthetic fun table$default (Lkweb/ElementCreator;Ljava/util/Map;Lkotlin/jvm/functions/Function2;ILjava/lang/Object;)Lkweb/TableElement; + public static final fun tbody (Lkweb/ElementCreator;Ljava/util/Map;Lkotlin/jvm/functions/Function2;)Lkweb/TbodyElement; + public static synthetic fun tbody$default (Lkweb/ElementCreator;Ljava/util/Map;Lkotlin/jvm/functions/Function2;ILjava/lang/Object;)Lkweb/TbodyElement; + public static final fun td (Lkweb/ElementCreator;Ljava/util/Map;Lkotlin/jvm/functions/Function2;)Lkweb/TdElement; + public static synthetic fun td$default (Lkweb/ElementCreator;Ljava/util/Map;Lkotlin/jvm/functions/Function2;ILjava/lang/Object;)Lkweb/TdElement; + public static final fun textArea (Lkweb/ElementCreator;Ljava/util/Map;Ljava/lang/Integer;Ljava/lang/Integer;Ljava/lang/Boolean;Lkotlin/jvm/functions/Function2;)Lkweb/TextAreaElement; + public static final fun textArea (Lkweb/ElementCreator;Ljava/util/Map;Lkotlin/jvm/functions/Function2;)Lkweb/TextAreaElement; + public static synthetic fun textArea$default (Lkweb/ElementCreator;Ljava/util/Map;Ljava/lang/Integer;Ljava/lang/Integer;Ljava/lang/Boolean;Lkotlin/jvm/functions/Function2;ILjava/lang/Object;)Lkweb/TextAreaElement; + public static synthetic fun textArea$default (Lkweb/ElementCreator;Ljava/util/Map;Lkotlin/jvm/functions/Function2;ILjava/lang/Object;)Lkweb/TextAreaElement; + public static final fun th (Lkweb/ElementCreator;Ljava/util/Map;Lkotlin/jvm/functions/Function2;)Lkweb/ThElement; + public static synthetic fun th$default (Lkweb/ElementCreator;Ljava/util/Map;Lkotlin/jvm/functions/Function2;ILjava/lang/Object;)Lkweb/ThElement; + public static final fun thead (Lkweb/ElementCreator;Ljava/util/Map;Lkotlin/jvm/functions/Function2;)Lkweb/TheadElement; + public static synthetic fun thead$default (Lkweb/ElementCreator;Ljava/util/Map;Lkotlin/jvm/functions/Function2;ILjava/lang/Object;)Lkweb/TheadElement; + public static final fun title (Lkweb/ElementCreator;Ljava/util/Map;Lkotlin/jvm/functions/Function2;)Lkweb/html/TitleElement; + public static synthetic fun title$default (Lkweb/ElementCreator;Ljava/util/Map;Lkotlin/jvm/functions/Function2;ILjava/lang/Object;)Lkweb/html/TitleElement; public static final fun toInt (Lkweb/state/KVar;)Lkweb/state/KVar; - public static final fun tr (Lkweb/ElementCreator;Ljava/util/Map;Lkotlin/jvm/functions/Function1;)Lkweb/TrElement; - public static synthetic fun tr$default (Lkweb/ElementCreator;Ljava/util/Map;Lkotlin/jvm/functions/Function1;ILjava/lang/Object;)Lkweb/TrElement; - public static final fun ul (Lkweb/ElementCreator;Ljava/util/Map;Lkotlin/jvm/functions/Function1;)Lkweb/ULElement; - public static synthetic fun ul$default (Lkweb/ElementCreator;Ljava/util/Map;Lkotlin/jvm/functions/Function1;ILjava/lang/Object;)Lkweb/ULElement; + public static final fun tr (Lkweb/ElementCreator;Ljava/util/Map;Lkotlin/jvm/functions/Function2;)Lkweb/TrElement; + public static synthetic fun tr$default (Lkweb/ElementCreator;Ljava/util/Map;Lkotlin/jvm/functions/Function2;ILjava/lang/Object;)Lkweb/TrElement; + public static final fun ul (Lkweb/ElementCreator;Ljava/util/Map;Lkotlin/jvm/functions/Function2;)Lkweb/ULElement; + public static synthetic fun ul$default (Lkweb/ElementCreator;Ljava/util/Map;Lkotlin/jvm/functions/Function2;ILjava/lang/Object;)Lkweb/ULElement; } public final class kweb/Scheme : java/lang/Enum { @@ -916,8 +916,8 @@ public final class kweb/html/Document : kweb/html/events/EventGenerator { public synthetic fun addEventListener (Ljava/lang/String;Ljava/util/Set;Ljava/lang/String;ZLkotlin/jvm/functions/Function1;)Ljava/lang/Object; public fun addEventListener (Ljava/lang/String;Ljava/util/Set;Ljava/lang/String;ZLkotlin/jvm/functions/Function1;)Lkweb/html/Document; public fun addImmediateEventCode (Ljava/lang/String;Ljava/lang/String;)V - public final fun body (Lkotlin/jvm/functions/Function1;)Lkweb/html/BodyElement; - public static synthetic fun body$default (Lkweb/html/Document;Lkotlin/jvm/functions/Function1;ILjava/lang/Object;)Lkweb/html/BodyElement; + public final fun body (Lkotlin/jvm/functions/Function2;)Lkweb/html/BodyElement; + public static synthetic fun body$default (Lkweb/html/Document;Lkotlin/jvm/functions/Function2;ILjava/lang/Object;)Lkweb/html/BodyElement; public final fun execCommand (Ljava/lang/String;)V public final fun getBody ()Lkweb/html/BodyElement; public fun getBrowser ()Lkweb/WebBrowser; @@ -930,8 +930,8 @@ public final class kweb/html/Document : kweb/html/events/EventGenerator { public final fun getOrigin (Lkotlin/coroutines/Continuation;)Ljava/lang/Object; public final fun getReceiver ()Lkweb/WebBrowser; public final fun getSessionStorage ()Lkweb/html/StorageReceiver; - public final fun head (Lkotlin/jvm/functions/Function1;)Lkweb/html/HeadElement; - public static synthetic fun head$default (Lkweb/html/Document;Lkotlin/jvm/functions/Function1;ILjava/lang/Object;)Lkweb/html/HeadElement; + public final fun head (Lkotlin/jvm/functions/Function2;)Lkweb/html/HeadElement; + public static synthetic fun head$default (Lkweb/html/Document;Lkotlin/jvm/functions/Function2;ILjava/lang/Object;)Lkweb/html/HeadElement; public final fun on (Ljava/lang/String;Z)Lkweb/html/events/OnReceiver; public static synthetic fun on$default (Lkweb/html/Document;Ljava/lang/String;ZILjava/lang/Object;)Lkweb/html/events/OnReceiver; } diff --git a/docs/src/dom.md b/docs/src/dom.md index 21ff30f873..ee38893770 100644 --- a/docs/src/dom.md +++ b/docs/src/dom.md @@ -27,7 +27,9 @@ attributes: {{#include ../../src/test/kotlin/kweb/docs/dom.kt:setattributes}} ``` -Attributes can also be specified in an `element` block: +The created [Element](https://docs.kweb.io/api/kweb-core/kweb/-element/index.html) +is passed to the `{block}` as a parameter, which can be used to set attributes on the +element, add listeners, or set the element's text or innerHtml: ```kotlin {{#include ../../src/test/kotlin/kweb/docs/dom.kt:attr2}} @@ -52,7 +54,6 @@ Alternatively we can use the `new {}` function to add children to a pre-existing ```kotlin {{#include ../../src/test/kotlin/kweb/docs/dom.kt:children_new}} - ``` ## Reading from the DOM diff --git a/src/main/kotlin/kweb/Element.kt b/src/main/kotlin/kweb/Element.kt index fec33a23b9..735d478e7c 100644 --- a/src/main/kotlin/kweb/Element.kt +++ b/src/main/kotlin/kweb/Element.kt @@ -685,19 +685,11 @@ open class Element( */ fun ELEMENT_TYPE.new( insertBefore: String? = null, - receiver: ElementCreator.() -> RETURN_VALUE_TYPE + receiver: ElementCreator.(ELEMENT_TYPE) -> RETURN_VALUE_TYPE ) : RETURN_VALUE_TYPE { return receiver( - /** - * Returns an [ElementCreator] which can be used to create new elements and add them - * as children of the receiver element. - * - * @receiver This will be the parent element of any elements created with the returned - * [ElementCreator] - * @Param position What position among the parent's children should the new element have? - */ - ElementCreator(element = this, insertBefore = insertBefore) + ElementCreator(element = this, insertBefore = insertBefore), this ) } diff --git a/src/main/kotlin/kweb/ElementCreator.kt b/src/main/kotlin/kweb/ElementCreator.kt index ebc7797e68..fd55f5e1fe 100755 --- a/src/main/kotlin/kweb/ElementCreator.kt +++ b/src/main/kotlin/kweb/ElementCreator.kt @@ -57,7 +57,7 @@ open class ElementCreator( * @param namespace If non-null elements will be created with [Document.createElementNS()](https://developer.mozilla.org/en-US/docs/Web/API/Document/createElementNS) * with the specified namespace. If null then Kweb will use [Document.createElement](https://developer.mozilla.org/en-US/docs/Web/API/Document/createElement). */ - fun element(tag: String, attributes: Map = attr, namespace: String? = null, new: (ElementCreator<*>.() -> Unit)? = null): Element { + fun element(tag: String, attributes: Map = attr, namespace: String? = null, new: (ElementCreator<*>.(Element) -> Unit)? = null): Element { val mutAttributes = HashMap(attributes) @@ -160,7 +160,7 @@ open class ElementCreator( } if (new != null) { - newElement.new { new() } + newElement.new { new(newElement) } } return newElement @@ -231,6 +231,9 @@ open class ElementCreator( @Deprecated("Use element instead (as of v0.12.8)", ReplaceWith("element", "kweb.ElementCreator.element")) val parent get() = element + @Deprecated("div { element { set(\"foo\", \"bar\")} } ===> div { it.set(\"foo\", \"bar\") }", + ReplaceWith("receiver(element)") + ) fun element(receiver : (PARENT_TYPE).() -> Unit) { receiver(element) } diff --git a/src/main/kotlin/kweb/html/Document.kt b/src/main/kotlin/kweb/html/Document.kt index 44ad059e56..267d245c2e 100755 --- a/src/main/kotlin/kweb/html/Document.kt +++ b/src/main/kotlin/kweb/html/Document.kt @@ -26,10 +26,10 @@ class Document(val receiver: WebBrowser) : EventGenerator { val body = BodyElement(receiver, "K_body") - fun body(new: (ElementCreator.() -> Unit)? = null) : BodyElement { + fun body(new: (ElementCreator.(BodyElement) -> Unit)? = null) : BodyElement { if (new != null) { val ec = ElementCreator(element = body, insertBefore = null) - new(ec) + new(ec, body) receiver.addCloseListener { ec.cleanup() } @@ -39,10 +39,10 @@ class Document(val receiver: WebBrowser) : EventGenerator { val head = HeadElement(receiver, "K_head") - fun head(new: (ElementCreator.() -> Unit)? = null) : HeadElement { + fun head(new: (ElementCreator.(HeadElement) -> Unit)? = null) : HeadElement { if (new != null) { val ec = ElementCreator(element = head, insertBefore = null) - new(ec) + new(ec, head) receiver.addCloseListener { ec.cleanup() } diff --git a/src/main/kotlin/kweb/prelude.kt b/src/main/kotlin/kweb/prelude.kt index e46ff06315..83c84c0333 100644 --- a/src/main/kotlin/kweb/prelude.kt +++ b/src/main/kotlin/kweb/prelude.kt @@ -23,10 +23,10 @@ import kotlin.collections.set fun ElementCreator.title( attributes: Map = emptyMap(), - new: (ElementCreator.() -> Unit)? = null + new: (ElementCreator.(TitleElement) -> Unit)? = null ): TitleElement { return TitleElement(element("title", attributes)).also { - if (new != null) new(ElementCreator(element = it, insertBefore = null)) + if (new != null) new(ElementCreator(element = it, insertBefore = null), it) } } @@ -34,10 +34,10 @@ open class ULElement(parent: Element) : Element(parent) fun ElementCreator.ul( attributes: Map = emptyMap(), - new: (ElementCreator.() -> Unit)? = null + new: (ElementCreator.(ULElement) -> Unit)? = null ): ULElement { return ULElement(element("ul", attributes)).also { - if (new != null) new(ElementCreator(element = it, insertBefore = null)) + if (new != null) new(ElementCreator(element = it, insertBefore = null), it) } } @@ -45,10 +45,10 @@ open class OLElement(parent: Element) : Element(parent) fun ElementCreator.ol( attributes: Map = emptyMap(), - new: (ElementCreator.() -> Unit)? = null + new: (ElementCreator.(OLElement) -> Unit)? = null ): OLElement { return OLElement(element("ol", attributes)).also { - if (new != null) new(ElementCreator(element = it, insertBefore = null)) + if (new != null) new(ElementCreator(element = it, insertBefore = null), it) } } @@ -56,10 +56,10 @@ open class LIElement(parent: Element) : Element(parent) fun ElementCreator.li( attributes: Map = emptyMap(), - new: (ElementCreator.() -> Unit)? = null + new: (ElementCreator.(LIElement) -> Unit)? = null ): LIElement { return LIElement(element("li", attributes)).also { - if (new != null) new(ElementCreator(element = it, insertBefore = null)) + if (new != null) new(ElementCreator(element = it, insertBefore = null), it) } } @@ -72,7 +72,7 @@ fun ElementCreator.button( attributes: Map = emptyMap(), type: ButtonType? = ButtonType.button, autofocus: Boolean? = null, - new: (ElementCreator.() -> Unit)? = null, + new: (ElementCreator.(ButtonElement) -> Unit)? = null, ): ButtonElement { return ButtonElement( element( @@ -81,7 +81,7 @@ fun ElementCreator.button( .set("autofocus", JsonPrimitive(autofocus)) ) ).also { - if (new != null) new(ElementCreator(element = it, insertBefore = null)) + if (new != null) new(ElementCreator(element = it, insertBefore = null), it) } } @@ -89,10 +89,10 @@ open class SpanElement(parent: Element) : Element(parent) fun ElementCreator.span( attributes: Map = emptyMap(), - new: (ElementCreator.() -> Unit)? = null + new: (ElementCreator.(SpanElement) -> Unit)? = null ): SpanElement { return SpanElement(element("span", attributes)).also { - if (new != null) new(ElementCreator(element = it, insertBefore = null)) + if (new != null) new(ElementCreator(element = it, insertBefore = null), it) } } @@ -100,10 +100,10 @@ open class DivElement(parent: Element) : Element(parent) fun ElementCreator.div( attributes: Map = emptyMap(), - new: (ElementCreator.() -> Unit)? = null + new: (ElementCreator.(DivElement) -> Unit)? = null ): DivElement { return DivElement(element("div", attributes)).also { - if (new != null) new(ElementCreator(element = it, insertBefore = null)) + if (new != null) new(ElementCreator(element = it, insertBefore = null), it) } } @@ -111,10 +111,10 @@ open class IElement(parent: Element) : Element(parent) fun ElementCreator.i( attributes: Map = emptyMap(), - new: (ElementCreator.() -> Unit)? = null + new: (ElementCreator.(IElement) -> Unit)? = null ): IElement { return IElement(element("i", attributes)).also { - if (new != null) new(ElementCreator(element = it, insertBefore = null)) + if (new != null) new(ElementCreator(element = it, insertBefore = null), it) } } @@ -122,10 +122,10 @@ open class FormElement(parent: Element) : Element(parent) fun ElementCreator.form( attributes: Map = emptyMap(), - new: (ElementCreator.() -> Unit)? = null + new: (ElementCreator.(FormElement) -> Unit)? = null ): FormElement { return FormElement(element("form", attributes)).also { - if (new != null) new(ElementCreator(element = it, insertBefore = null)) + if (new != null) new(ElementCreator(element = it, insertBefore = null), it) } } @@ -157,10 +157,10 @@ open class AElement(parent: Element) : Element(parent) { fun ElementCreator.a( attributes: Map = emptyMap(), href: String? = null, - new: (ElementCreator.() -> Unit)? = null + new: (ElementCreator.(AElement) -> Unit)? = null ): AElement { return AElement(element("a", attributes.set("href", JsonPrimitive(href)))).also { - if (new != null) new(ElementCreator(element = it, insertBefore = null)) + if (new != null) new(ElementCreator(element = it, insertBefore = null), it) } } @@ -169,10 +169,10 @@ open class OptionElement(parent: Element) : Element(parent) fun ElementCreator.option( attributes: Map = emptyMap(), - new: (ElementCreator.() -> Unit)? = null + new: (ElementCreator.(OptionElement) -> Unit)? = null ): OptionElement { return OptionElement(element("option", attributes)).also { - if (new != null) new(ElementCreator(element = it, insertBefore = null)) + if (new != null) new(ElementCreator(element = it, insertBefore = null), it) } } @@ -180,10 +180,10 @@ open class H1Element(parent: Element) : Element(parent) fun ElementCreator.h1( attributes: Map = emptyMap(), - new: (ElementCreator.() -> Unit)? = null + new: (ElementCreator.(H1Element) -> Unit)? = null ): H1Element { return H1Element(element("h1", attributes)).also { - if (new != null) new(ElementCreator(element = it, insertBefore = null)) + if (new != null) new(ElementCreator(element = it, insertBefore = null), it) } } @@ -191,10 +191,10 @@ open class H2Element(parent: Element) : Element(parent) fun ElementCreator.h2( attributes: Map = emptyMap(), - new: (ElementCreator.() -> Unit)? = null + new: (ElementCreator.(H2Element) -> Unit)? = null ): H2Element { return H2Element(element("h2", attributes)).also { - if (new != null) new(ElementCreator(element = it, insertBefore = null)) + if (new != null) new(ElementCreator(element = it, insertBefore = null), it) } } @@ -202,10 +202,10 @@ open class H3Element(parent: Element) : Element(parent) fun ElementCreator.h3( attributes: Map = emptyMap(), - new: (ElementCreator.() -> Unit)? = null + new: (ElementCreator.(H3Element) -> Unit)? = null ): H3Element { return H3Element(element("h3", attributes)).also { - if (new != null) new(ElementCreator(element = it, insertBefore = null)) + if (new != null) new(ElementCreator(element = it, insertBefore = null), it) } } @@ -213,10 +213,10 @@ open class H4Element(parent: Element) : Element(parent) fun ElementCreator.h4( attributes: Map = emptyMap(), - new: (ElementCreator.() -> Unit)? = null + new: (ElementCreator.(H4Element) -> Unit)? = null ): H4Element { return H4Element(element("h4", attributes)).also { - if (new != null) new(ElementCreator(element = it, insertBefore = null)) + if (new != null) new(ElementCreator(element = it, insertBefore = null), it) } } @@ -224,10 +224,10 @@ open class H5Element(parent: Element) : Element(parent) fun ElementCreator.h5( attributes: Map = emptyMap(), - new: (ElementCreator.() -> Unit)? = null + new: (ElementCreator.(H5Element) -> Unit)? = null ): H5Element { return H5Element(element("h5", attributes)).also { - if (new != null) new(ElementCreator(element = it, insertBefore = null)) + if (new != null) new(ElementCreator(element = it, insertBefore = null), it) } } @@ -235,10 +235,10 @@ open class PElement(parent: Element) : Element(parent) fun ElementCreator.p( attributes: Map = emptyMap(), - new: (ElementCreator.() -> Unit)? = null + new: (ElementCreator.(PElement) -> Unit)? = null ): PElement { return PElement(element("p", attributes)).also { - if (new != null) new(ElementCreator(element = it, insertBefore = null)) + if (new != null) new(ElementCreator(element = it, insertBefore = null), it) } } @@ -246,10 +246,10 @@ open class NavElement(parent: Element) : Element(parent) fun ElementCreator.nav( attributes: Map = emptyMap(), - new: (ElementCreator.() -> Unit)? = null + new: (ElementCreator.(NavElement) -> Unit)? = null ): NavElement { return NavElement(element("nav", attributes)).also { - if (new != null) new(ElementCreator(element = it, insertBefore = null)) + if (new != null) new(ElementCreator(element = it, insertBefore = null), it) } } @@ -257,10 +257,10 @@ open class SectionElement(parent: Element) : Element(parent) fun ElementCreator.section( attributes: Map = emptyMap(), - new: (ElementCreator.() -> Unit)? = null + new: (ElementCreator.(SectionElement) -> Unit)? = null ): SectionElement { return SectionElement(element("section", attributes)).also { - if (new != null) new(ElementCreator(element = it, insertBefore = null)) + if (new != null) new(ElementCreator(element = it, insertBefore = null), it) } } @@ -268,10 +268,10 @@ open class ImageElement(parent: Element) : Element(parent) fun ElementCreator.img( attributes: Map = emptyMap(), - new: (ElementCreator.() -> Unit)? = null + new: (ElementCreator.(ImageElement) -> Unit)? = null ): ImageElement { return ImageElement(element("img", attributes)).also { - if (new != null) new(ElementCreator(element = it, insertBefore = null)) + if (new != null) new(ElementCreator(element = it, insertBefore = null), it) } } @@ -280,7 +280,7 @@ open class CanvasElement(parent: Element) : Element(parent) fun ElementCreator.canvas( attributes: Map = emptyMap(), width: Int, height: Int, - new: (ElementCreator.() -> Unit)? = null + new: (ElementCreator.(CanvasElement) -> Unit)? = null ): CanvasElement { return CanvasElement( element( @@ -289,7 +289,7 @@ fun ElementCreator.canvas( .set("width", JsonPrimitive(width)).set("height", JsonPrimitive(height)) ) ).also { - if (new != null) new(ElementCreator(element = it, insertBefore = null)) + if (new != null) new(ElementCreator(element = it, insertBefore = null), it) } } @@ -297,10 +297,10 @@ open class BrElement(parent: Element) : Element(parent) fun ElementCreator.br( attributes: Map = emptyMap(), - new: (ElementCreator.() -> Unit)? = null + new: (ElementCreator.(BrElement) -> Unit)? = null ): BrElement { return BrElement(element("br", attributes)).also { - if (new != null) new(ElementCreator(element = it, insertBefore = null)) + if (new != null) new(ElementCreator(element = it, insertBefore = null), it) } } @@ -309,7 +309,7 @@ open class MetaElement(parent: Element) : Element(parent) fun ElementCreator.meta( attributes: Map = emptyMap(), name: String, content: String, httpEquiv: String? = null, charset: String? = null, - new: (ElementCreator.() -> Unit)? = null + new: (ElementCreator.(MetaElement) -> Unit)? = null ): MetaElement { return MetaElement( element( @@ -319,7 +319,7 @@ fun ElementCreator.meta( .set("charset", JsonPrimitive(charset)) ) ).also { - if (new != null) new(ElementCreator(element = it, insertBefore = null)) + if (new != null) new(ElementCreator(element = it, insertBefore = null), it) } } @@ -356,7 +356,7 @@ fun ElementCreator.input( initialValue: String? = null, size: Int? = null, placeholder: String? = null, - new: (ElementCreator.() -> Unit)? = null + new: (ElementCreator.(InputElement) -> Unit)? = null ): InputElement { return InputElement( element( @@ -367,14 +367,14 @@ fun ElementCreator.input( .set("size", JsonPrimitive(size)) ), initialValue = initialValue ).also { - if (new != null) new(ElementCreator(element = it, insertBefore = null)) + if (new != null) new(ElementCreator(element = it, insertBefore = null), it) } } fun ElementCreator.textArea( attributes: Map = emptyMap(), rows: Int? = null, cols: Int? = null, required: Boolean? = null, - new: (ElementCreator.() -> Unit)? = null + new: (ElementCreator.(TextAreaElement) -> Unit)? = null ): TextAreaElement { return TextAreaElement( element( @@ -383,7 +383,7 @@ fun ElementCreator.textArea( .set("required", JsonPrimitive(required)) ) ).also { - if (new != null) new(ElementCreator(element = it, insertBefore = null)) + if (new != null) new(ElementCreator(element = it, insertBefore = null), it) } } @@ -399,7 +399,7 @@ class SelectElement(parent: Element, initialValue: String? = null) : fun ElementCreator.select( attributes: Map = emptyMap(), name: String? = null, required: Boolean? = null, - new: (ElementCreator.() -> Unit)? = null + new: (ElementCreator.(SelectElement) -> Unit)? = null ): SelectElement { return SelectElement( element( @@ -408,7 +408,7 @@ fun ElementCreator.select( .set("required", JsonPrimitive(required)) ) ).also { - if (new != null) new(ElementCreator(element = it, insertBefore = null)) + if (new != null) new(ElementCreator(element = it, insertBefore = null), it) } } @@ -422,10 +422,10 @@ class TextAreaElement(parent: Element, initialValue: String? = null) : ValueElem */ fun ElementCreator.textArea( attributes: Map = emptyMap(), - new: (ElementCreator.() -> Unit)? = null + new: (ElementCreator.(TextAreaElement) -> Unit)? = null ): TextAreaElement { return TextAreaElement(element("textArea", attributes)).also { - if (new != null) new(ElementCreator(element = it, insertBefore = null)) + if (new != null) new(ElementCreator(element = it, insertBefore = null), it) } } @@ -437,10 +437,10 @@ open class LabelElement(wrapped: Element) : Element(wrapped) { fun ElementCreator.label( attributes: Map = emptyMap(), - new: (ElementCreator.() -> Unit)? = null + new: (ElementCreator.(LabelElement) -> Unit)? = null ): LabelElement { return LabelElement(element("label", attributes)).also { - if (new != null) new(ElementCreator(element = it, insertBefore = null)) + if (new != null) new(ElementCreator(element = it, insertBefore = null), it) } } @@ -733,10 +733,10 @@ fun ElementCreator<*>.fileInput(name: String? = null, initialValue: String? = nu fun ElementCreator.table( attributes: Map = emptyMap(), - new: (ElementCreator.() -> Unit)? = null + new: (ElementCreator.(TableElement) -> Unit)? = null ): TableElement { return TableElement(element("table", attributes)).also { - if (new != null) new(ElementCreator(element = it, insertBefore = null)) + if (new != null) new(ElementCreator(element = it, insertBefore = null), it) } } @@ -744,50 +744,50 @@ open class TableElement(parent: Element) : Element(parent) fun ElementCreator.thead( attributes: Map = emptyMap(), - new: (ElementCreator.() -> Unit)? = null + new: (ElementCreator.(TheadElement) -> Unit)? = null ): TheadElement { return TheadElement(element("thead", attributes)).also { - if (new != null) new(ElementCreator(element = it, insertBefore = null)) + if (new != null) new(ElementCreator(element = it, insertBefore = null), it) } } open class TheadElement(parent: Element) : Element(parent) fun ElementCreator.th( attributes: Map = emptyMap(), - new: (ElementCreator.() -> Unit)? = null + new: (ElementCreator.(ThElement) -> Unit)? = null ): ThElement { return ThElement(element("th", attributes)).also { - if (new != null) new(ElementCreator(element = it, insertBefore = null)) + if (new != null) new(ElementCreator(element = it, insertBefore = null), it) } } open class ThElement(parent: Element) : Element(parent) fun ElementCreator.tbody( attributes: Map = emptyMap(), - new: (ElementCreator.() -> Unit)? = null + new: (ElementCreator.(TbodyElement) -> Unit)? = null ): TbodyElement { return TbodyElement(element("tbody", attributes)).also { - if (new != null) new(ElementCreator(element = it, insertBefore = null)) + if (new != null) new(ElementCreator(element = it, insertBefore = null), it) } } open class TbodyElement(parent: Element) : Element(parent) fun ElementCreator.tr( attributes: Map = emptyMap(), - new: (ElementCreator.() -> Unit)? = null + new: (ElementCreator.(TrElement) -> Unit)? = null ): TrElement { return TrElement(element("tr", attributes)).also { - if (new != null) new(ElementCreator(element = it, insertBefore = null)) + if (new != null) new(ElementCreator(element = it, insertBefore = null), it) } } open class TrElement(parent: Element) : Element(parent) fun ElementCreator.td( attributes: Map = emptyMap(), - new: (ElementCreator.() -> Unit)? = null + new: (ElementCreator.(TdElement) -> Unit)? = null ): TdElement { return TdElement(element("td", attributes)).also { - if (new != null) new(ElementCreator(element = it, insertBefore = null)) + if (new != null) new(ElementCreator(element = it, insertBefore = null), it) } } class TdElement(parent: Element) : Element(parent) diff --git a/src/test/kotlin/kweb/HistoryTest.kt b/src/test/kotlin/kweb/HistoryTest.kt index 7615ec7665..41f6394ff0 100644 --- a/src/test/kotlin/kweb/HistoryTest.kt +++ b/src/test/kotlin/kweb/HistoryTest.kt @@ -93,8 +93,8 @@ class HistoryTestApp { route { path("/{num}") { p -> render(p["num"]!!.toInt()) { num -> - a { - element { + a { aElement -> + with(aElement) { href = "/${num + 1}" text("Next ($num)") } diff --git a/src/test/kotlin/kweb/demos/todo/TodoApp.kt b/src/test/kotlin/kweb/demos/todo/TodoApp.kt index 6c745a16a9..073d4c791a 100755 --- a/src/test/kotlin/kweb/demos/todo/TodoApp.kt +++ b/src/test/kotlin/kweb/demos/todo/TodoApp.kt @@ -84,7 +84,7 @@ class TodoApp { }) } - private fun ElementCreator<*>.pageBorderAndTitle(title: String, content: ElementCreator.() -> Unit) { + private fun ElementCreator<*>.pageBorderAndTitle(title: String, content: ElementCreator.(DivElement) -> Unit) { div(fomantic.ui.main.container) { div(fomantic.column) { div(fomantic.ui.vertical.segment) { @@ -106,7 +106,7 @@ class TodoApp { div(fomantic.ui.vertical.segment) { h1(fomantic.ui.dividing.header).text(title) - content(this) + content(it) } } } diff --git a/src/test/kotlin/kweb/docs/components.kt b/src/test/kotlin/kweb/docs/components.kt index 04a30e0dbd..bd97526f7e 100644 --- a/src/test/kotlin/kweb/docs/components.kt +++ b/src/test/kotlin/kweb/docs/components.kt @@ -52,9 +52,9 @@ class BulmaInput( override fun render(elementCreator: ElementCreator<*>) : InputElement { with(elementCreator) { - val renderedInput = input(type = type) { + val renderedInput = input(type = type) { inputElement -> var inputClassList: KVal> = kval(listOf("input")) - element { + with(inputElement) { if (color != null) { inputClassList += color.map { listOf(it.cssClassName) } diff --git a/src/test/kotlin/kweb/docs/dom.kt b/src/test/kotlin/kweb/docs/dom.kt index 3c6d2724c7..d3fc80f317 100644 --- a/src/test/kotlin/kweb/docs/dom.kt +++ b/src/test/kotlin/kweb/docs/dom.kt @@ -55,8 +55,8 @@ button.delete() // ANCHOR_END: delete // ANCHOR: attr2 -button { - element { +button { btnEl -> + with(btnEl) { classes("bigbutton") this["autofocus"] = true text("Click Me!") diff --git a/src/test/kotlin/kweb/docs/gettingstarted.kt b/src/test/kotlin/kweb/docs/gettingstarted.kt index d9b8f4ffec..4e0092c57e 100644 --- a/src/test/kotlin/kweb/docs/gettingstarted.kt +++ b/src/test/kotlin/kweb/docs/gettingstarted.kt @@ -36,10 +36,7 @@ Kweb(port = 16097) { doc.body { ul { // We can modify the UL element we just created in an element {} block - element { - // Here we add a CSS class to the UL element - classes("list") - } + it.classes("list") // We can define functions as an extension to ElementCreator allowing us to use it // within the DSL fun ElementCreator.createMessage(x: Int) {