Skip to content

Commit a5c6068

Browse files
authored
feat(ckui): support directly pass in
1 parent 0ef9583 commit a5c6068

File tree

1 file changed

+22
-1
lines changed

1 file changed

+22
-1
lines changed

libs/CKUI.lib.js

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// ==UserScript==
22
// @name CKUI
33
// @namespace ckylin-script-lib-ckui
4-
// @version 2.4.0
4+
// @version 2.4.1
55
// @description A modern, dependency-free UI library for Tampermonkey scripts
66
// @match http://*
77
// @match https://*
@@ -2509,20 +2509,41 @@ if (typeof unsafeWindow === 'undefined' || !unsafeWindow) {
25092509
}
25102510

25112511
html(options) {
2512+
2513+
if (typeof options === 'string') {
2514+
return this.addField({
2515+
type: 'html',
2516+
content: options
2517+
});
2518+
}
25122519
return this.addField({
25132520
type: 'html',
25142521
...options
25152522
});
25162523
}
25172524

25182525
element(options) {
2526+
2527+
if (options instanceof Node || typeof options === 'function') {
2528+
return this.addField({
2529+
type: 'element',
2530+
element: options
2531+
});
2532+
}
25192533
return this.addField({
25202534
type: 'element',
25212535
...options
25222536
});
25232537
}
25242538

25252539
elements(options) {
2540+
2541+
if (Array.isArray(options) || options instanceof NodeList) {
2542+
return this.addField({
2543+
type: 'elements',
2544+
elements: Array.from(options)
2545+
});
2546+
}
25262547
return this.addField({
25272548
type: 'elements',
25282549
...options

0 commit comments

Comments
 (0)