From d96afd67e161034c78be38326f3e6627d6eb1fcc Mon Sep 17 00:00:00 2001 From: Ian Harrigan Date: Tue, 9 Jul 2024 09:26:36 +0200 Subject: [PATCH] toggleClass --- haxe/ui/core/Component.hx | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/haxe/ui/core/Component.hx b/haxe/ui/core/Component.hx index 2ebf97704..e43a80e4a 100644 --- a/haxe/ui/core/Component.hx +++ b/haxe/ui/core/Component.hx @@ -1420,6 +1420,14 @@ class Component extends ComponentImpl } } + public function toggleClass(name:String, invalidate:Bool = true, recursive:Bool = false) { + if (classes.indexOf(name) == -1) { + addClass(name, invalidate, recursive); + } else { + removeClass(name, invalidate, recursive); + } + } + /** * A string representation of the `css` classes associated with this component */