tiny-essentials 1.16.1 → 1.17.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/legacy/crypto/decrypt.cjs +1 -0
- package/dist/legacy/crypto/decrypt.d.mts +1 -0
- package/dist/legacy/crypto/decrypt.mjs +1 -0
- package/dist/legacy/crypto/encrypt.cjs +1 -0
- package/dist/legacy/crypto/encrypt.d.mts +1 -0
- package/dist/legacy/crypto/encrypt.mjs +1 -0
- package/dist/legacy/get/decimalColor.cjs +1 -0
- package/dist/legacy/get/decimalColor.d.mts +1 -0
- package/dist/legacy/get/decimalColor.mjs +1 -0
- package/dist/legacy/get/pagination.cjs +1 -0
- package/dist/legacy/get/pagination.d.mts +1 -0
- package/dist/legacy/get/pagination.mjs +1 -0
- package/dist/legacy/get/queryUrlByName.cjs +1 -0
- package/dist/legacy/get/queryUrlByName.d.mts +1 -0
- package/dist/legacy/get/queryUrlByName.mjs +1 -0
- package/dist/legacy/get/queryUrlJSON.cjs +1 -0
- package/dist/legacy/get/queryUrlJSON.d.mts +1 -0
- package/dist/legacy/get/queryUrlJSON.mjs +1 -0
- package/dist/legacy/get/super_string_filter.cjs +1 -0
- package/dist/legacy/get/super_string_filter.d.mts +1 -0
- package/dist/legacy/get/super_string_filter.mjs +1 -0
- package/dist/legacy/get/versionCheck.cjs +1 -0
- package/dist/legacy/get/versionCheck.d.mts +1 -0
- package/dist/legacy/get/versionCheck.mjs +1 -0
- package/dist/legacy/http/HTTP-1.0.cjs +2 -0
- package/dist/legacy/http/HTTP-1.0.mjs +2 -0
- package/dist/legacy/http/auth.cjs +1 -0
- package/dist/legacy/http/auth.d.mts +1 -0
- package/dist/legacy/http/auth.mjs +1 -0
- package/dist/legacy/http/check_domain.cjs +11 -0
- package/dist/legacy/http/check_domain.d.mts +3 -0
- package/dist/legacy/http/check_domain.mjs +11 -0
- package/dist/legacy/http/csrfTokenAnalyze.cjs +1 -0
- package/dist/legacy/http/csrfTokenAnalyze.d.mts +1 -0
- package/dist/legacy/http/csrfTokenAnalyze.mjs +1 -0
- package/dist/legacy/http/domainValidator.cjs +1 -0
- package/dist/legacy/http/domainValidator.d.mts +1 -0
- package/dist/legacy/http/domainValidator.mjs +1 -0
- package/dist/legacy/http/errorsCallback.cjs +1 -0
- package/dist/legacy/http/errorsCallback.d.mts +1 -0
- package/dist/legacy/http/errorsCallback.mjs +1 -0
- package/dist/legacy/http/fetch/json.cjs +1 -0
- package/dist/legacy/http/fetch/json.d.mts +1 -0
- package/dist/legacy/http/fetch/json.mjs +1 -0
- package/dist/legacy/http/fetch/text.cjs +1 -0
- package/dist/legacy/http/fetch/text.d.mts +1 -0
- package/dist/legacy/http/fetch/text.mjs +1 -0
- package/dist/legacy/http/fileCache.cjs +1 -0
- package/dist/legacy/http/fileCache.d.mts +1 -0
- package/dist/legacy/http/fileCache.mjs +1 -0
- package/dist/legacy/http/getDomainURL.cjs +1 -0
- package/dist/legacy/http/getDomainURL.d.mts +1 -0
- package/dist/legacy/http/getDomainURL.mjs +1 -0
- package/dist/legacy/http/userIP.cjs +1 -0
- package/dist/legacy/http/userIP.d.mts +1 -0
- package/dist/legacy/http/userIP.mjs +1 -0
- package/dist/legacy/libs/capitalize.cjs +1 -0
- package/dist/legacy/libs/capitalize.d.mts +1 -0
- package/dist/legacy/libs/capitalize.mjs +1 -0
- package/dist/legacy/libs/convertBytes.cjs +2 -0
- package/dist/legacy/libs/convertBytes.mjs +2 -0
- package/dist/legacy/libs/custom_module_loader.cjs +2 -0
- package/dist/legacy/libs/custom_module_loader.mjs +2 -0
- package/dist/legacy/libs/dice.cjs +2 -0
- package/dist/legacy/libs/dice.mjs +2 -0
- package/dist/legacy/libs/markdown.cjs +1 -0
- package/dist/legacy/libs/markdown.mjs +1 -0
- package/dist/legacy/libs/percentage.cjs +1 -0
- package/dist/legacy/libs/percentage.mjs +1 -0
- package/dist/legacy/libs/regex/getLetter.cjs +2 -0
- package/dist/legacy/libs/regex/getLetter.d.mts +2 -0
- package/dist/legacy/libs/regex/getLetter.mjs +2 -0
- package/dist/legacy/libs/rule3.cjs +1 -0
- package/dist/legacy/libs/rule3.mjs +1 -0
- package/dist/legacy/momentjs/getAge.cjs +1 -0
- package/dist/legacy/momentjs/getAge.d.mts +1 -0
- package/dist/legacy/momentjs/getAge.mjs +1 -0
- package/dist/legacy/momentjs/timeDuration.cjs +1 -0
- package/dist/legacy/momentjs/timeDuration.d.mts +1 -0
- package/dist/legacy/momentjs/timeDuration.mjs +1 -0
- package/dist/legacy/socket.io/antiFlood/install.cjs +1 -0
- package/dist/legacy/socket.io/antiFlood/install.d.mts +1 -0
- package/dist/legacy/socket.io/antiFlood/install.mjs +1 -0
- package/dist/legacy/socket.io/antiFlood/verify.cjs +1 -0
- package/dist/legacy/socket.io/antiFlood/verify.d.mts +1 -0
- package/dist/legacy/socket.io/antiFlood/verify.mjs +1 -0
- package/dist/legacy/socket.io/cookie-session.cjs +1 -0
- package/dist/legacy/socket.io/cookie-session.d.mts +1 -0
- package/dist/legacy/socket.io/cookie-session.mjs +1 -0
- package/dist/legacy/socket.io/discord.cjs +1 -0
- package/dist/legacy/socket.io/discord.d.mts +1 -0
- package/dist/legacy/socket.io/discord.mjs +1 -0
- package/dist/v1/TinyAfterScrollWatcher.js +49 -26
- package/dist/v1/TinyAfterScrollWatcher.min.js +1 -1
- package/dist/v1/TinyBasicsEs.js +559 -71
- package/dist/v1/TinyBasicsEs.min.js +1 -1
- package/dist/v1/TinyDragger.js +486 -47
- package/dist/v1/TinyDragger.min.js +1 -1
- package/dist/v1/TinyEssentials.js +2545 -98
- package/dist/v1/TinyEssentials.min.js +1 -1
- package/dist/v1/TinyHtml.js +486 -47
- package/dist/v1/TinyHtml.min.js +1 -1
- package/dist/v1/TinySmartScroller.js +6230 -0
- package/dist/v1/TinySmartScroller.min.js +1 -0
- package/dist/v1/TinyUploadClicker.js +1538 -72
- package/dist/v1/TinyUploadClicker.min.js +1 -1
- package/dist/v1/UltraRandomMsgGen.js +995 -0
- package/dist/v1/UltraRandomMsgGen.min.js +1 -0
- package/dist/v1/basics/html.cjs +74 -24
- package/dist/v1/basics/html.d.mts +38 -15
- package/dist/v1/basics/html.mjs +63 -20
- package/dist/v1/build/TinySmartScroller.cjs +7 -0
- package/dist/v1/build/TinySmartScroller.d.mts +3 -0
- package/dist/v1/build/TinySmartScroller.mjs +2 -0
- package/dist/v1/build/UltraRandomMsgGen.cjs +7 -0
- package/dist/v1/build/UltraRandomMsgGen.d.mts +3 -0
- package/dist/v1/build/UltraRandomMsgGen.mjs +2 -0
- package/dist/v1/index.cjs +4 -0
- package/dist/v1/index.d.mts +3 -1
- package/dist/v1/index.mjs +3 -1
- package/dist/v1/libs/TinyAfterScrollWatcher.cjs +49 -26
- package/dist/v1/libs/TinyAfterScrollWatcher.d.mts +17 -14
- package/dist/v1/libs/TinyAfterScrollWatcher.mjs +50 -24
- package/dist/v1/libs/TinyHtml.cjs +486 -47
- package/dist/v1/libs/TinyHtml.d.mts +352 -139
- package/dist/v1/libs/TinyHtml.mjs +431 -47
- package/dist/v1/libs/TinySmartScroller.cjs +976 -0
- package/dist/v1/libs/TinySmartScroller.d.mts +458 -0
- package/dist/v1/libs/TinySmartScroller.mjs +856 -0
- package/dist/v1/libs/UltraRandomMsgGen.cjs +956 -0
- package/dist/v1/libs/UltraRandomMsgGen.d.mts +390 -0
- package/dist/v1/libs/UltraRandomMsgGen.mjs +825 -0
- package/docs/v1/README.md +2 -0
- package/docs/v1/basics/html.md +17 -2
- package/docs/v1/libs/TinyAfterScrollWatcher.md +54 -4
- package/docs/v1/libs/TinyHtml.md +197 -8
- package/docs/v1/libs/TinySmartScroller.md +523 -0
- package/docs/v1/libs/UltraRandomMsgGen.md +289 -0
- package/package.json +1 -1
package/dist/v1/TinyBasicsEs.js
CHANGED
|
@@ -3023,20 +3023,22 @@ function saveJsonFile(filename, data, spaces = 2) {
|
|
|
3023
3023
|
}
|
|
3024
3024
|
|
|
3025
3025
|
/**
|
|
3026
|
-
*
|
|
3027
|
-
*
|
|
3028
|
-
* @
|
|
3029
|
-
* @
|
|
3030
|
-
* @
|
|
3031
|
-
* @
|
|
3032
|
-
* @
|
|
3033
|
-
|
|
3034
|
-
|
|
3035
|
-
|
|
3036
|
-
* @
|
|
3037
|
-
* @
|
|
3026
|
+
* @typedef {Object} FetchTemplateOptions
|
|
3027
|
+
* @property {string} [method="GET"] - HTTP method to use (GET, POST, etc.).
|
|
3028
|
+
* @property {any} [body] - Request body (only for methods like POST, PUT).
|
|
3029
|
+
* @property {number} [timeout=0] - Timeout in milliseconds (ignored if signal is provided).
|
|
3030
|
+
* @property {number} [retries=0] - Number of retry attempts (ignored if signal is provided).
|
|
3031
|
+
* @property {Headers|Record<string, *>} [headers={}] - Additional headers.
|
|
3032
|
+
* @property {AbortSignal|null} [signal] - External AbortSignal; disables timeout and retries.
|
|
3033
|
+
*/
|
|
3034
|
+
|
|
3035
|
+
/**
|
|
3036
|
+
* @param {string} url - The full URL to fetch data from.
|
|
3037
|
+
* @param {FetchTemplateOptions} [options] - Optional settings.
|
|
3038
|
+
* @returns {Promise<Response>} Result data.
|
|
3039
|
+
* @throws {Error} Throws if fetch fails, times out.
|
|
3038
3040
|
*/
|
|
3039
|
-
async function
|
|
3041
|
+
async function fetchTemplate(
|
|
3040
3042
|
url,
|
|
3041
3043
|
{ method = 'GET', body, timeout = 0, retries = 0, headers = {}, signal = null } = {},
|
|
3042
3044
|
) {
|
|
@@ -3095,17 +3097,7 @@ async function fetchJson(
|
|
|
3095
3097
|
if (timer) clearTimeout(timer);
|
|
3096
3098
|
|
|
3097
3099
|
if (!response.ok) throw new Error(`HTTP error: ${response.status} ${response.statusText}`);
|
|
3098
|
-
|
|
3099
|
-
const contentType = response.headers.get('content-type') || '';
|
|
3100
|
-
if (!contentType.includes('application/json'))
|
|
3101
|
-
throw new Error(`Unexpected content-type: ${contentType}`);
|
|
3102
|
-
|
|
3103
|
-
const data = await response.json();
|
|
3104
|
-
|
|
3105
|
-
if (!Array.isArray(data) && !isJsonObject(data))
|
|
3106
|
-
throw new Error('Received invalid data instead of valid JSON.');
|
|
3107
|
-
|
|
3108
|
-
return data;
|
|
3100
|
+
return response;
|
|
3109
3101
|
} catch (err) {
|
|
3110
3102
|
lastError = /** @type {Error} */ (err);
|
|
3111
3103
|
if (signal) break; // if an external signal came, it does not retry
|
|
@@ -3119,6 +3111,63 @@ async function fetchJson(
|
|
|
3119
3111
|
);
|
|
3120
3112
|
}
|
|
3121
3113
|
|
|
3114
|
+
/**
|
|
3115
|
+
* Loads and parses a JSON from a remote URL using Fetch API.
|
|
3116
|
+
*
|
|
3117
|
+
* @param {string} url - The full URL to fetch JSON from.
|
|
3118
|
+
* @param {Object} [options] - Optional settings.
|
|
3119
|
+
* @returns {Promise<any[] | Record<string | number | symbol, unknown>>} Parsed JSON object.
|
|
3120
|
+
* @throws {Error} Throws if fetch fails, times out, or returns invalid JSON.
|
|
3121
|
+
*/
|
|
3122
|
+
async function fetchJson(url, options) {
|
|
3123
|
+
return new Promise((resolve, reject) => {
|
|
3124
|
+
fetchTemplate(url, options)
|
|
3125
|
+
.then(async (res) => {
|
|
3126
|
+
const contentType = res.headers.get('content-type') || '';
|
|
3127
|
+
if (!contentType.includes('application/json'))
|
|
3128
|
+
throw new Error(`Unexpected content-type: ${contentType}`);
|
|
3129
|
+
|
|
3130
|
+
const data = await res.json();
|
|
3131
|
+
|
|
3132
|
+
if (!Array.isArray(data) && !isJsonObject(data))
|
|
3133
|
+
throw new Error('Received invalid data instead of valid JSON.');
|
|
3134
|
+
|
|
3135
|
+
return resolve(data);
|
|
3136
|
+
})
|
|
3137
|
+
.catch(reject);
|
|
3138
|
+
});
|
|
3139
|
+
}
|
|
3140
|
+
|
|
3141
|
+
/**
|
|
3142
|
+
* Loads a remote file as a Blob using Fetch API.
|
|
3143
|
+
*
|
|
3144
|
+
* @param {string} url - The full URL to fetch the file from.
|
|
3145
|
+
* @param {Object} [options] - Optional fetch options.
|
|
3146
|
+
* @param {string[]} [allowedMimeTypes] - Optional list of accepted MIME types (e.g., ['image/jpeg']).
|
|
3147
|
+
* @returns {Promise<Blob>} - The fetched file as a Blob.
|
|
3148
|
+
* @throws {Error} Throws if fetch fails, response is not ok, or MIME type is not allowed.
|
|
3149
|
+
*/
|
|
3150
|
+
async function fetchBlob(url, allowedMimeTypes, options) {
|
|
3151
|
+
return new Promise((resolve, reject) => {
|
|
3152
|
+
fetchTemplate(url, options)
|
|
3153
|
+
.then(async (res) => {
|
|
3154
|
+
const contentType = res.headers.get('content-type') || '';
|
|
3155
|
+
|
|
3156
|
+
if (
|
|
3157
|
+
Array.isArray(allowedMimeTypes) &&
|
|
3158
|
+
allowedMimeTypes.length > 0 &&
|
|
3159
|
+
!allowedMimeTypes.some((type) => contentType.includes(type))
|
|
3160
|
+
) {
|
|
3161
|
+
throw new Error(`Blocked MIME type: ${contentType}`);
|
|
3162
|
+
}
|
|
3163
|
+
|
|
3164
|
+
const data = await res.blob();
|
|
3165
|
+
return resolve(data);
|
|
3166
|
+
})
|
|
3167
|
+
.catch(reject);
|
|
3168
|
+
});
|
|
3169
|
+
}
|
|
3170
|
+
|
|
3122
3171
|
///////////////////////////////////////////////////////////////////////////////
|
|
3123
3172
|
|
|
3124
3173
|
/**
|
|
@@ -3705,6 +3754,21 @@ const {
|
|
|
3705
3754
|
* @typedef {Element|Window} ElementAndWindow
|
|
3706
3755
|
*/
|
|
3707
3756
|
|
|
3757
|
+
/**
|
|
3758
|
+
* Represents a raw DOM element/window/document or an instance of TinyHtml.
|
|
3759
|
+
* This type is used to abstract interactions with both plain elements
|
|
3760
|
+
* and wrapped elements via the TinyHtml class.
|
|
3761
|
+
*
|
|
3762
|
+
* @typedef {ElementAndWinAndDoc|TinyHtml} TinyElementAndWinAndDoc
|
|
3763
|
+
*/
|
|
3764
|
+
|
|
3765
|
+
/**
|
|
3766
|
+
* Represents a value that can be either a DOM Element, or the global Window object, or the document object.
|
|
3767
|
+
* Useful for functions that operate generically on scrollable or measurable targets.
|
|
3768
|
+
*
|
|
3769
|
+
* @typedef {Element|Window|Document} ElementAndWinAndDoc
|
|
3770
|
+
*/
|
|
3771
|
+
|
|
3708
3772
|
/**
|
|
3709
3773
|
* A parameter type used for filtering or matching elements.
|
|
3710
3774
|
* It can be:
|
|
@@ -3721,7 +3785,7 @@ const {
|
|
|
3721
3785
|
* Elements accepted as constructor values for TinyHtml.
|
|
3722
3786
|
* These include common DOM elements and root containers.
|
|
3723
3787
|
*
|
|
3724
|
-
* @typedef {Window|Element|Document} ConstructorElValues
|
|
3788
|
+
* @typedef {Window|Element|Document|Text} ConstructorElValues
|
|
3725
3789
|
*/
|
|
3726
3790
|
|
|
3727
3791
|
/**
|
|
@@ -3842,40 +3906,114 @@ class TinyHtml_TinyHtml {
|
|
|
3842
3906
|
|
|
3843
3907
|
static Utils = { ...collision_namespaceObject };
|
|
3844
3908
|
|
|
3909
|
+
/**
|
|
3910
|
+
* Creates a new DOM element with the specified tag name and options, then wraps it in a TinyHtml instance.
|
|
3911
|
+
*
|
|
3912
|
+
* @param {string} tagName - The tag name of the element to create (e.g., 'div', 'span').
|
|
3913
|
+
* @param {ElementCreationOptions} ops - Optional settings for creating the element.
|
|
3914
|
+
* @returns {TinyHtml} A TinyHtml instance wrapping the newly created DOM element.
|
|
3915
|
+
* @throws {TypeError} If tagName is not a string or ops is not an object.
|
|
3916
|
+
*/
|
|
3917
|
+
static createElement(tagName, ops) {
|
|
3918
|
+
if (typeof tagName !== 'string')
|
|
3919
|
+
throw new TypeError(`[TinyHtml] createElement(): The tagName must be a string.`);
|
|
3920
|
+
if (typeof ops !== 'undefined' && typeof ops !== 'object')
|
|
3921
|
+
throw new TypeError(`[TinyHtml] createElement(): The ops must be a object.`);
|
|
3922
|
+
return new TinyHtml_TinyHtml(document.createElement(tagName, ops));
|
|
3923
|
+
}
|
|
3924
|
+
|
|
3925
|
+
/**
|
|
3926
|
+
* Creates a new TinyHtml instance that wraps a DOM TextNode.
|
|
3927
|
+
*
|
|
3928
|
+
* This method is useful when you want to insert raw text content into the DOM
|
|
3929
|
+
* without it being interpreted as HTML. The returned instance behaves like any
|
|
3930
|
+
* other TinyHtml element and can be appended or manipulated as needed.
|
|
3931
|
+
*
|
|
3932
|
+
* @param {string} value - The plain text content to be wrapped in a TextNode.
|
|
3933
|
+
* @returns {TinyHtml} A TinyHtml instance wrapping the newly created DOM TextNode.
|
|
3934
|
+
* @throws {TypeError} If the provided value is not a string.
|
|
3935
|
+
*/
|
|
3936
|
+
static createTextNode(value) {
|
|
3937
|
+
if (typeof value !== 'string')
|
|
3938
|
+
throw new TypeError(`[TinyHtml] createTextNode(): The value must be a string.`);
|
|
3939
|
+
return new TinyHtml_TinyHtml(document.createTextNode(value));
|
|
3940
|
+
}
|
|
3941
|
+
|
|
3942
|
+
/**
|
|
3943
|
+
* Creates an HTMLElement or TextNode from an HTML string.
|
|
3944
|
+
* Supports both elements and plain text.
|
|
3945
|
+
*
|
|
3946
|
+
* @param {string} htmlString - The HTML string to convert.
|
|
3947
|
+
* @returns {TinyHtml} - A single HTMLElement or TextNode.
|
|
3948
|
+
*/
|
|
3949
|
+
static createElementFromHTML(htmlString) {
|
|
3950
|
+
const template = document.createElement('template');
|
|
3951
|
+
htmlString = htmlString.trim();
|
|
3952
|
+
|
|
3953
|
+
// If it's only text (e.g., no "<" tag), return a TextNode
|
|
3954
|
+
if (!htmlString.startsWith('<')) {
|
|
3955
|
+
return TinyHtml_TinyHtml.createTextNode(htmlString);
|
|
3956
|
+
}
|
|
3957
|
+
|
|
3958
|
+
template.innerHTML = htmlString;
|
|
3959
|
+
if (!(template.content.firstChild instanceof Element)) throw new Error('');
|
|
3960
|
+
return new TinyHtml_TinyHtml(template.content.firstChild);
|
|
3961
|
+
}
|
|
3962
|
+
|
|
3845
3963
|
/**
|
|
3846
3964
|
* Queries the document for the first element matching the CSS selector and wraps it in a TinyHtml instance.
|
|
3847
3965
|
*
|
|
3848
3966
|
* @param {string} selector - A valid CSS selector string.
|
|
3849
|
-
* @
|
|
3850
|
-
* @
|
|
3967
|
+
* @param {Document|Element} elem - Target element.
|
|
3968
|
+
* @returns {TinyHtml|null} A TinyHtml instance wrapping the matched element.
|
|
3851
3969
|
*/
|
|
3852
|
-
static query(selector) {
|
|
3853
|
-
const newEl =
|
|
3854
|
-
if (!newEl)
|
|
3970
|
+
static query(selector, elem = document) {
|
|
3971
|
+
const newEl = elem.querySelector(selector);
|
|
3972
|
+
if (!newEl) return null;
|
|
3855
3973
|
return new TinyHtml_TinyHtml(newEl);
|
|
3856
3974
|
}
|
|
3857
3975
|
|
|
3976
|
+
/**
|
|
3977
|
+
* Queries the element for the first element matching the CSS selector and wraps it in a TinyHtml instance.
|
|
3978
|
+
*
|
|
3979
|
+
* @param {string} selector - A valid CSS selector string.
|
|
3980
|
+
* @returns {TinyHtml|null} A TinyHtml instance wrapping the matched element.
|
|
3981
|
+
*/
|
|
3982
|
+
querySelector(selector) {
|
|
3983
|
+
return TinyHtml_TinyHtml.query(selector, TinyHtml_TinyHtml._preElem(this, 'query'));
|
|
3984
|
+
}
|
|
3985
|
+
|
|
3858
3986
|
/**
|
|
3859
3987
|
* Queries the document for all elements matching the CSS selector and wraps them in TinyHtml instances.
|
|
3860
3988
|
*
|
|
3861
3989
|
* @param {string} selector - A valid CSS selector string.
|
|
3990
|
+
* @param {Document|Element} elem - Target element.
|
|
3862
3991
|
* @returns {TinyHtml[]} An array of TinyHtml instances wrapping the matched elements.
|
|
3863
3992
|
*/
|
|
3864
|
-
static queryAll(selector) {
|
|
3865
|
-
const newEls =
|
|
3993
|
+
static queryAll(selector, elem = document) {
|
|
3994
|
+
const newEls = elem.querySelectorAll(selector);
|
|
3866
3995
|
return TinyHtml_TinyHtml.toTinyElm([...newEls]);
|
|
3867
3996
|
}
|
|
3868
3997
|
|
|
3998
|
+
/**
|
|
3999
|
+
* Queries the element for all elements matching the CSS selector and wraps them in TinyHtml instances.
|
|
4000
|
+
*
|
|
4001
|
+
* @param {string} selector - A valid CSS selector string.
|
|
4002
|
+
* @returns {TinyHtml[]} An array of TinyHtml instances wrapping the matched elements.
|
|
4003
|
+
*/
|
|
4004
|
+
querySelectorAll(selector) {
|
|
4005
|
+
return TinyHtml_TinyHtml.queryAll(selector, TinyHtml_TinyHtml._preElem(this, 'queryAll'));
|
|
4006
|
+
}
|
|
4007
|
+
|
|
3869
4008
|
/**
|
|
3870
4009
|
* Retrieves an element by its ID and wraps it in a TinyHtml instance.
|
|
3871
4010
|
*
|
|
3872
4011
|
* @param {string} selector - The ID of the element to retrieve.
|
|
3873
|
-
* @returns {TinyHtml} A TinyHtml instance wrapping the found element.
|
|
3874
|
-
* @throws {Error} If no element is found with the specified ID.
|
|
4012
|
+
* @returns {TinyHtml|null} A TinyHtml instance wrapping the found element.
|
|
3875
4013
|
*/
|
|
3876
4014
|
static getById(selector) {
|
|
3877
4015
|
const newEl = document.getElementById(selector);
|
|
3878
|
-
if (!newEl)
|
|
4016
|
+
if (!newEl) return null;
|
|
3879
4017
|
return new TinyHtml_TinyHtml(newEl);
|
|
3880
4018
|
}
|
|
3881
4019
|
|
|
@@ -3883,13 +4021,24 @@ class TinyHtml_TinyHtml {
|
|
|
3883
4021
|
* Retrieves all elements with the specified class name and wraps them in TinyHtml instances.
|
|
3884
4022
|
*
|
|
3885
4023
|
* @param {string} selector - The class name to search for.
|
|
4024
|
+
* @param {Document|Element} elem - Target element.
|
|
3886
4025
|
* @returns {TinyHtml[]} An array of TinyHtml instances wrapping the found elements.
|
|
3887
4026
|
*/
|
|
3888
|
-
static getByClassName(selector) {
|
|
3889
|
-
const newEls =
|
|
4027
|
+
static getByClassName(selector, elem = document) {
|
|
4028
|
+
const newEls = elem.getElementsByClassName(selector);
|
|
3890
4029
|
return TinyHtml_TinyHtml.toTinyElm([...newEls]);
|
|
3891
4030
|
}
|
|
3892
4031
|
|
|
4032
|
+
/**
|
|
4033
|
+
* Retrieves all elements with the specified class name and wraps them in TinyHtml instances.
|
|
4034
|
+
*
|
|
4035
|
+
* @param {string} selector - The class name to search for.
|
|
4036
|
+
* @returns {TinyHtml[]} An array of TinyHtml instances wrapping the found elements.
|
|
4037
|
+
*/
|
|
4038
|
+
getElementsByClassName(selector) {
|
|
4039
|
+
return TinyHtml_TinyHtml.getByClassName(selector, TinyHtml_TinyHtml._preElem(this, 'getByClassName'));
|
|
4040
|
+
}
|
|
4041
|
+
|
|
3893
4042
|
/**
|
|
3894
4043
|
* Retrieves all elements with the specified name attribute and wraps them in TinyHtml instances.
|
|
3895
4044
|
*
|
|
@@ -3907,13 +4056,30 @@ class TinyHtml_TinyHtml {
|
|
|
3907
4056
|
*
|
|
3908
4057
|
* @param {string} localName - The local name (tag) of the elements to search for.
|
|
3909
4058
|
* @param {string|null} [namespaceURI='http://www.w3.org/1999/xhtml'] - The namespace URI to search within.
|
|
4059
|
+
* @param {Document|Element} elem - Target element.
|
|
3910
4060
|
* @returns {TinyHtml[]} An array of TinyHtml instances wrapping the found elements.
|
|
3911
4061
|
*/
|
|
3912
|
-
static getByTagNameNS(localName, namespaceURI = 'http://www.w3.org/1999/xhtml') {
|
|
3913
|
-
const newEls =
|
|
4062
|
+
static getByTagNameNS(localName, namespaceURI = 'http://www.w3.org/1999/xhtml', elem = document) {
|
|
4063
|
+
const newEls = elem.getElementsByTagNameNS(namespaceURI, localName);
|
|
3914
4064
|
return TinyHtml_TinyHtml.toTinyElm([...newEls]);
|
|
3915
4065
|
}
|
|
3916
4066
|
|
|
4067
|
+
/**
|
|
4068
|
+
* Retrieves all elements with the specified local tag name within the given namespace URI,
|
|
4069
|
+
* and wraps them in TinyHtml instances.
|
|
4070
|
+
*
|
|
4071
|
+
* @param {string} localName - The local name (tag) of the elements to search for.
|
|
4072
|
+
* @param {string|null} [namespaceURI='http://www.w3.org/1999/xhtml'] - The namespace URI to search within.
|
|
4073
|
+
* @returns {TinyHtml[]} An array of TinyHtml instances wrapping the found elements.
|
|
4074
|
+
*/
|
|
4075
|
+
getElementsByTagNameNS(localName, namespaceURI = 'http://www.w3.org/1999/xhtml') {
|
|
4076
|
+
return TinyHtml_TinyHtml.getByTagNameNS(
|
|
4077
|
+
localName,
|
|
4078
|
+
namespaceURI,
|
|
4079
|
+
TinyHtml_TinyHtml._preElem(this, 'getByTagNameNS'),
|
|
4080
|
+
);
|
|
4081
|
+
}
|
|
4082
|
+
|
|
3917
4083
|
//////////////////////////////////////////////////////////////////
|
|
3918
4084
|
|
|
3919
4085
|
/**
|
|
@@ -4194,6 +4360,45 @@ class TinyHtml_TinyHtml {
|
|
|
4194
4360
|
return TinyHtml_TinyHtml._preElemTemplate(elems, where, [Element, Window], ['Element', 'Window']);
|
|
4195
4361
|
}
|
|
4196
4362
|
|
|
4363
|
+
/**
|
|
4364
|
+
* Ensures the input is returned as an array.
|
|
4365
|
+
* Useful to normalize operations across multiple or single element/window/document elements.
|
|
4366
|
+
*
|
|
4367
|
+
* @param {TinyElementAndWinAndDoc|TinyElementAndWinAndDoc[]} elems - A single element/window element or array of html elements.
|
|
4368
|
+
* @param {string} where - The method or context name where validation is being called.
|
|
4369
|
+
* @returns {ElementAndWindow[]} - Always returns an array of element/window elements.
|
|
4370
|
+
* @readonly
|
|
4371
|
+
*/
|
|
4372
|
+
static _preElemsAndWinAndDoc(elems, where) {
|
|
4373
|
+
const result = TinyHtml_TinyHtml._preElemsTemplate(
|
|
4374
|
+
elems,
|
|
4375
|
+
where,
|
|
4376
|
+
[Element, Window, Document],
|
|
4377
|
+
['Element', 'Window', 'Document'],
|
|
4378
|
+
);
|
|
4379
|
+
return result.map((elem) => (!(elem instanceof Document) ? elem : elem.documentElement));
|
|
4380
|
+
}
|
|
4381
|
+
|
|
4382
|
+
/**
|
|
4383
|
+
* Ensures the input is returned as an single element/window/document element.
|
|
4384
|
+
* Useful to normalize operations across multiple or single element/window/document elements.
|
|
4385
|
+
*
|
|
4386
|
+
* @param {TinyElementAndWinAndDoc|TinyElementAndWinAndDoc[]} elems - A single element/window element or array of html elements.
|
|
4387
|
+
* @param {string} where - The method or context name where validation is being called.
|
|
4388
|
+
* @returns {ElementAndWindow} - Always returns an single element/window element.
|
|
4389
|
+
* @readonly
|
|
4390
|
+
*/
|
|
4391
|
+
static _preElemAndWinAndDoc(elems, where) {
|
|
4392
|
+
const result = TinyHtml_TinyHtml._preElemTemplate(
|
|
4393
|
+
elems,
|
|
4394
|
+
where,
|
|
4395
|
+
[Element, Window, Document],
|
|
4396
|
+
['Element', 'Window', 'Document'],
|
|
4397
|
+
);
|
|
4398
|
+
if (result instanceof Document) return result.documentElement;
|
|
4399
|
+
return result;
|
|
4400
|
+
}
|
|
4401
|
+
|
|
4197
4402
|
/**
|
|
4198
4403
|
* Normalizes and converts one or more DOM elements (or TinyHtml instances)
|
|
4199
4404
|
* into an array of `TinyHtml` instances.
|
|
@@ -4540,12 +4745,13 @@ class TinyHtml_TinyHtml {
|
|
|
4540
4745
|
* @param {string} key - The key under which the data will be stored.
|
|
4541
4746
|
* @param {any} value - The value to store.
|
|
4542
4747
|
* @param {boolean} [isPrivate=false] - Whether to store the data in the private store.
|
|
4543
|
-
* @returns {
|
|
4748
|
+
* @returns {TinyElement}
|
|
4544
4749
|
*/
|
|
4545
4750
|
static setData(el, key, value, isPrivate = false) {
|
|
4546
4751
|
const data = TinyHtml_TinyHtml._dataSelector[!isPrivate ? 'public' : 'private']('setData', el);
|
|
4547
4752
|
if (typeof key !== 'string') throw new TypeError('The key must be a string.');
|
|
4548
4753
|
data[key] = value;
|
|
4754
|
+
return el;
|
|
4549
4755
|
}
|
|
4550
4756
|
|
|
4551
4757
|
/**
|
|
@@ -4554,7 +4760,7 @@ class TinyHtml_TinyHtml {
|
|
|
4554
4760
|
* @param {string} key - The key under which the data will be stored.
|
|
4555
4761
|
* @param {any} value - The value to store.
|
|
4556
4762
|
* @param {boolean} [isPrivate=false] - Whether to store the data in the private store.
|
|
4557
|
-
* @returns {
|
|
4763
|
+
* @returns {TinyElement}
|
|
4558
4764
|
*/
|
|
4559
4765
|
setData(key, value, isPrivate = false) {
|
|
4560
4766
|
return TinyHtml_TinyHtml.setData(this, key, value, isPrivate);
|
|
@@ -4901,18 +5107,21 @@ class TinyHtml_TinyHtml {
|
|
|
4901
5107
|
/**
|
|
4902
5108
|
* Appends child elements or strings to the end of the target element(s).
|
|
4903
5109
|
*
|
|
4904
|
-
* @param {TinyElement
|
|
5110
|
+
* @param {TinyElement} el - The target element(s) to receive children.
|
|
4905
5111
|
* @param {...(TinyNode | TinyNode[] | string)} children - The child elements or text to append.
|
|
5112
|
+
* @returns {TinyElement}
|
|
4906
5113
|
*/
|
|
4907
5114
|
static append(el, ...children) {
|
|
4908
5115
|
const elem = TinyHtml_TinyHtml._preElem(el, 'append');
|
|
4909
5116
|
elem.append(...TinyHtml_TinyHtml._appendChecker('append', ...children));
|
|
5117
|
+
return el;
|
|
4910
5118
|
}
|
|
4911
5119
|
|
|
4912
5120
|
/**
|
|
4913
5121
|
* Appends child elements or strings to the end of the target element(s).
|
|
4914
5122
|
*
|
|
4915
5123
|
* @param {...(TinyNode | TinyNode[] | string)} children - The child elements or text to append.
|
|
5124
|
+
* @returns {TinyElement}
|
|
4916
5125
|
*/
|
|
4917
5126
|
append(...children) {
|
|
4918
5127
|
return TinyHtml_TinyHtml.append(this, ...children);
|
|
@@ -4921,18 +5130,21 @@ class TinyHtml_TinyHtml {
|
|
|
4921
5130
|
/**
|
|
4922
5131
|
* Prepends child elements or strings to the beginning of the target element(s).
|
|
4923
5132
|
*
|
|
4924
|
-
* @param {TinyElement
|
|
5133
|
+
* @param {TinyElement} el - The target element(s) to receive children.
|
|
4925
5134
|
* @param {...(TinyNode | TinyNode[] | string)} children - The child elements or text to prepend.
|
|
5135
|
+
* @returns {TinyElement}
|
|
4926
5136
|
*/
|
|
4927
5137
|
static prepend(el, ...children) {
|
|
4928
5138
|
const elem = TinyHtml_TinyHtml._preElem(el, 'prepend');
|
|
4929
5139
|
elem.prepend(...TinyHtml_TinyHtml._appendChecker('prepend', ...children));
|
|
5140
|
+
return el;
|
|
4930
5141
|
}
|
|
4931
5142
|
|
|
4932
5143
|
/**
|
|
4933
5144
|
* Prepends child elements or strings to the beginning of the target element(s).
|
|
4934
5145
|
*
|
|
4935
5146
|
* @param {...(TinyNode | TinyNode[] | string)} children - The child elements or text to prepend.
|
|
5147
|
+
* @returns {TinyElement}
|
|
4936
5148
|
*/
|
|
4937
5149
|
prepend(...children) {
|
|
4938
5150
|
return TinyHtml_TinyHtml.prepend(this, ...children);
|
|
@@ -4941,18 +5153,21 @@ class TinyHtml_TinyHtml {
|
|
|
4941
5153
|
/**
|
|
4942
5154
|
* Inserts elements or strings immediately before the target element(s) in the DOM.
|
|
4943
5155
|
*
|
|
4944
|
-
* @param {TinyElement
|
|
5156
|
+
* @param {TinyElement} el - The target element(s) before which new content is inserted.
|
|
4945
5157
|
* @param {...(TinyNode | TinyNode[] | string)} children - Elements or text to insert before the target.
|
|
5158
|
+
* @returns {TinyElement}
|
|
4946
5159
|
*/
|
|
4947
5160
|
static before(el, ...children) {
|
|
4948
5161
|
const elem = TinyHtml_TinyHtml._preElem(el, 'before');
|
|
4949
5162
|
elem.before(...TinyHtml_TinyHtml._appendChecker('before', ...children));
|
|
5163
|
+
return el;
|
|
4950
5164
|
}
|
|
4951
5165
|
|
|
4952
5166
|
/**
|
|
4953
5167
|
* Inserts elements or strings immediately before the target element(s) in the DOM.
|
|
4954
5168
|
*
|
|
4955
5169
|
* @param {...(TinyNode | TinyNode[] | string)} children - Elements or text to insert before the target.
|
|
5170
|
+
* @returns {TinyElement}
|
|
4956
5171
|
*/
|
|
4957
5172
|
before(...children) {
|
|
4958
5173
|
return TinyHtml_TinyHtml.before(this, ...children);
|
|
@@ -4961,18 +5176,21 @@ class TinyHtml_TinyHtml {
|
|
|
4961
5176
|
/**
|
|
4962
5177
|
* Inserts elements or strings immediately after the target element(s) in the DOM.
|
|
4963
5178
|
*
|
|
4964
|
-
* @param {TinyElement
|
|
5179
|
+
* @param {TinyElement} el - The target element(s) after which new content is inserted.
|
|
4965
5180
|
* @param {...(TinyNode | TinyNode[] | string)} children - Elements or text to insert after the target.
|
|
5181
|
+
* @returns {TinyElement}
|
|
4966
5182
|
*/
|
|
4967
5183
|
static after(el, ...children) {
|
|
4968
5184
|
const elem = TinyHtml_TinyHtml._preElem(el, 'after');
|
|
4969
5185
|
elem.after(...TinyHtml_TinyHtml._appendChecker('after', ...children));
|
|
5186
|
+
return el;
|
|
4970
5187
|
}
|
|
4971
5188
|
|
|
4972
5189
|
/**
|
|
4973
5190
|
* Inserts elements or strings immediately after the target element(s) in the DOM.
|
|
4974
5191
|
*
|
|
4975
5192
|
* @param {...(TinyNode | TinyNode[] | string)} children - Elements or text to insert after the target.
|
|
5193
|
+
* @returns {TinyElement}
|
|
4976
5194
|
*/
|
|
4977
5195
|
after(...children) {
|
|
4978
5196
|
return TinyHtml_TinyHtml.after(this, ...children);
|
|
@@ -4981,18 +5199,21 @@ class TinyHtml_TinyHtml {
|
|
|
4981
5199
|
/**
|
|
4982
5200
|
* Replaces the target element(s) in the DOM with new elements or text.
|
|
4983
5201
|
*
|
|
4984
|
-
* @param {TinyElement
|
|
5202
|
+
* @param {TinyElement} el - The element(s) to be replaced.
|
|
4985
5203
|
* @param {...(TinyNode | TinyNode[] | string)} newNodes - New elements or text to replace the target.
|
|
5204
|
+
* @returns {TinyElement}
|
|
4986
5205
|
*/
|
|
4987
5206
|
static replaceWith(el, ...newNodes) {
|
|
4988
5207
|
const elem = TinyHtml_TinyHtml._preElem(el, 'replaceWith');
|
|
4989
5208
|
elem.replaceWith(...TinyHtml_TinyHtml._appendChecker('replaceWith', ...newNodes));
|
|
5209
|
+
return el;
|
|
4990
5210
|
}
|
|
4991
5211
|
|
|
4992
5212
|
/**
|
|
4993
5213
|
* Replaces the target element(s) in the DOM with new elements or text.
|
|
4994
5214
|
*
|
|
4995
5215
|
* @param {...(TinyNode | TinyNode[] | string)} newNodes - New elements or text to replace the target.
|
|
5216
|
+
* @returns {TinyElement}
|
|
4996
5217
|
*/
|
|
4997
5218
|
replaceWith(...newNodes) {
|
|
4998
5219
|
return TinyHtml_TinyHtml.replaceWith(this, ...newNodes);
|
|
@@ -5003,6 +5224,7 @@ class TinyHtml_TinyHtml {
|
|
|
5003
5224
|
*
|
|
5004
5225
|
* @param {TinyNode | TinyNode[]} el - The element(s) to append.
|
|
5005
5226
|
* @param {TinyNode | TinyNode[]} targets - Target element(s) where content will be appended.
|
|
5227
|
+
* @returns {TinyNode|TinyNode[]}
|
|
5006
5228
|
*/
|
|
5007
5229
|
static appendTo(el, targets) {
|
|
5008
5230
|
const elems = TinyHtml_TinyHtml._preNodeElems(el, 'appendTo');
|
|
@@ -5012,12 +5234,14 @@ class TinyHtml_TinyHtml {
|
|
|
5012
5234
|
target.appendChild(i === tars.length - 1 ? elem : elem.cloneNode(true)),
|
|
5013
5235
|
);
|
|
5014
5236
|
});
|
|
5237
|
+
return el;
|
|
5015
5238
|
}
|
|
5016
5239
|
|
|
5017
5240
|
/**
|
|
5018
5241
|
* Appends the given element(s) to each target element in sequence.
|
|
5019
5242
|
*
|
|
5020
5243
|
* @param {TinyNode | TinyNode[]} targets - Target element(s) where content will be appended.
|
|
5244
|
+
* @returns {TinyNode|TinyNode[]}
|
|
5021
5245
|
*/
|
|
5022
5246
|
appendTo(targets) {
|
|
5023
5247
|
return TinyHtml_TinyHtml.appendTo(this, targets);
|
|
@@ -5028,6 +5252,7 @@ class TinyHtml_TinyHtml {
|
|
|
5028
5252
|
*
|
|
5029
5253
|
* @param {TinyElement | TinyElement[]} el - The element(s) to prepend.
|
|
5030
5254
|
* @param {TinyElement | TinyElement[]} targets - Target element(s) where content will be prepended.
|
|
5255
|
+
* @returns {TinyElement|TinyElement[]}
|
|
5031
5256
|
*/
|
|
5032
5257
|
static prependTo(el, targets) {
|
|
5033
5258
|
const elems = TinyHtml_TinyHtml._preElems(el, 'prependTo');
|
|
@@ -5038,12 +5263,14 @@ class TinyHtml_TinyHtml {
|
|
|
5038
5263
|
.reverse()
|
|
5039
5264
|
.forEach((elem) => target.prepend(i === tars.length - 1 ? elem : elem.cloneNode(true)));
|
|
5040
5265
|
});
|
|
5266
|
+
return el;
|
|
5041
5267
|
}
|
|
5042
5268
|
|
|
5043
5269
|
/**
|
|
5044
5270
|
* Prepends the given element(s) to each target element in sequence.
|
|
5045
5271
|
*
|
|
5046
5272
|
* @param {TinyElement | TinyElement[]} targets - Target element(s) where content will be prepended.
|
|
5273
|
+
* @returns {TinyElement|TinyElement[]}
|
|
5047
5274
|
*/
|
|
5048
5275
|
prependTo(targets) {
|
|
5049
5276
|
return TinyHtml_TinyHtml.prependTo(this, targets);
|
|
@@ -5055,6 +5282,7 @@ class TinyHtml_TinyHtml {
|
|
|
5055
5282
|
* @param {TinyNode | TinyNode[]} el - The element(s) to insert.
|
|
5056
5283
|
* @param {TinyNode | TinyNode[]} target - The reference element where insertion happens.
|
|
5057
5284
|
* @param {TinyNode | TinyNode[] | null} [child=null] - Optional child to insert before, defaults to target.
|
|
5285
|
+
* @returns {TinyNode|TinyNode[]}
|
|
5058
5286
|
*/
|
|
5059
5287
|
static insertBefore(el, target, child = null) {
|
|
5060
5288
|
const elem = TinyHtml_TinyHtml._preNodeElem(el, 'insertBefore');
|
|
@@ -5062,6 +5290,7 @@ class TinyHtml_TinyHtml {
|
|
|
5062
5290
|
const childNode = TinyHtml_TinyHtml._preNodeElemWithNull(child, 'insertBefore');
|
|
5063
5291
|
if (!targ.parentNode) throw new Error('');
|
|
5064
5292
|
targ.parentNode.insertBefore(elem, childNode || targ);
|
|
5293
|
+
return el;
|
|
5065
5294
|
}
|
|
5066
5295
|
|
|
5067
5296
|
/**
|
|
@@ -5069,6 +5298,7 @@ class TinyHtml_TinyHtml {
|
|
|
5069
5298
|
*
|
|
5070
5299
|
* @param {TinyNode | TinyNode[]} target - The reference element where insertion happens.
|
|
5071
5300
|
* @param {TinyNode | TinyNode[] | null} [child=null] - Optional child to insert before, defaults to target.
|
|
5301
|
+
* @returns {TinyNode|TinyNode[]}
|
|
5072
5302
|
*/
|
|
5073
5303
|
insertBefore(target, child) {
|
|
5074
5304
|
return TinyHtml_TinyHtml.insertBefore(this, target, child);
|
|
@@ -5080,6 +5310,7 @@ class TinyHtml_TinyHtml {
|
|
|
5080
5310
|
* @param {TinyNode | TinyNode[]} el - The element(s) to insert.
|
|
5081
5311
|
* @param {TinyNode | TinyNode[]} target - The reference element where insertion happens.
|
|
5082
5312
|
* @param {TinyNode | TinyNode[] | null} [child=null] - Optional child to insert after, defaults to target.
|
|
5313
|
+
* @returns {TinyNode|TinyNode[]}
|
|
5083
5314
|
*/
|
|
5084
5315
|
static insertAfter(el, target, child = null) {
|
|
5085
5316
|
const elem = TinyHtml_TinyHtml._preNodeElem(el, 'insertAfter');
|
|
@@ -5087,6 +5318,7 @@ class TinyHtml_TinyHtml {
|
|
|
5087
5318
|
const childNode = TinyHtml_TinyHtml._preNodeElemWithNull(child, 'insertBefore');
|
|
5088
5319
|
if (!targ.parentNode) throw new Error('');
|
|
5089
5320
|
targ.parentNode.insertBefore(elem, childNode || targ.nextSibling);
|
|
5321
|
+
return el;
|
|
5090
5322
|
}
|
|
5091
5323
|
|
|
5092
5324
|
/**
|
|
@@ -5094,6 +5326,7 @@ class TinyHtml_TinyHtml {
|
|
|
5094
5326
|
*
|
|
5095
5327
|
* @param {TinyNode | TinyNode[]} target - The reference element where insertion happens.
|
|
5096
5328
|
* @param {TinyNode | TinyNode[] | null} [child=null] - Optional child to insert after, defaults to target.
|
|
5329
|
+
* @returns {TinyNode|TinyNode[]}
|
|
5097
5330
|
*/
|
|
5098
5331
|
insertAfter(target, child) {
|
|
5099
5332
|
return TinyHtml_TinyHtml.insertAfter(this, target, child);
|
|
@@ -5105,6 +5338,7 @@ class TinyHtml_TinyHtml {
|
|
|
5105
5338
|
*
|
|
5106
5339
|
* @param {TinyNode | TinyNode[]} el - The new element(s) to insert.
|
|
5107
5340
|
* @param {TinyNode | TinyNode[]} targets - The elements to be replaced.
|
|
5341
|
+
* @returns {TinyNode|TinyNode[]}
|
|
5108
5342
|
*/
|
|
5109
5343
|
static replaceAll(el, targets) {
|
|
5110
5344
|
const elems = TinyHtml_TinyHtml._preNodeElems(el, 'replaceAll');
|
|
@@ -5116,6 +5350,7 @@ class TinyHtml_TinyHtml {
|
|
|
5116
5350
|
parent.replaceChild(i === tars.length - 1 ? elem : elem.cloneNode(true), target);
|
|
5117
5351
|
});
|
|
5118
5352
|
});
|
|
5353
|
+
return el;
|
|
5119
5354
|
}
|
|
5120
5355
|
|
|
5121
5356
|
/**
|
|
@@ -5123,6 +5358,7 @@ class TinyHtml_TinyHtml {
|
|
|
5123
5358
|
* If multiple targets exist, the inserted elements are cloned accordingly.
|
|
5124
5359
|
*
|
|
5125
5360
|
* @param {TinyNode | TinyNode[]} targets - The elements to be replaced.
|
|
5361
|
+
* @returns {TinyNode|TinyNode[]}
|
|
5126
5362
|
*/
|
|
5127
5363
|
replaceAll(targets) {
|
|
5128
5364
|
return TinyHtml_TinyHtml.replaceAll(this, targets);
|
|
@@ -5146,7 +5382,12 @@ class TinyHtml_TinyHtml {
|
|
|
5146
5382
|
throw new Error(
|
|
5147
5383
|
`[TinyHtml] You are trying to put a TinyHtml inside another TinyHtml in constructor.`,
|
|
5148
5384
|
);
|
|
5149
|
-
if (
|
|
5385
|
+
if (
|
|
5386
|
+
!(el instanceof Element) &&
|
|
5387
|
+
!(el instanceof Window) &&
|
|
5388
|
+
!(el instanceof Document) &&
|
|
5389
|
+
!(el instanceof Text)
|
|
5390
|
+
)
|
|
5150
5391
|
throw new Error(`[TinyHtml] Invalid Target in constructor.`);
|
|
5151
5392
|
this.#el = el;
|
|
5152
5393
|
}
|
|
@@ -5596,6 +5837,7 @@ class TinyHtml_TinyHtml {
|
|
|
5596
5837
|
* @param {TinyHtmlElement|TinyHtmlElement[]} el - The element to inspect.
|
|
5597
5838
|
* @param {string|Object} prop - The property name or an object with key-value pairs
|
|
5598
5839
|
* @param {string|null} [value=null] - The value to set (if `prop` is a string)
|
|
5840
|
+
* @returns {TinyHtmlElement|TinyHtmlElement[]}
|
|
5599
5841
|
*/
|
|
5600
5842
|
static setStyle(el, prop, value = null) {
|
|
5601
5843
|
TinyHtml_TinyHtml._preHtmlElems(el, 'setStyle').forEach((elem) => {
|
|
@@ -5608,6 +5850,7 @@ class TinyHtml_TinyHtml {
|
|
|
5608
5850
|
}
|
|
5609
5851
|
} else elem.style.setProperty(TinyHtml_TinyHtml.toStyleKc(prop), value);
|
|
5610
5852
|
});
|
|
5853
|
+
return el;
|
|
5611
5854
|
}
|
|
5612
5855
|
|
|
5613
5856
|
/**
|
|
@@ -5618,6 +5861,7 @@ class TinyHtml_TinyHtml {
|
|
|
5618
5861
|
*
|
|
5619
5862
|
* @param {string|Object} prop - The property name or an object with key-value pairs
|
|
5620
5863
|
* @param {string|null} [value=null] - The value to set (if `prop` is a string)
|
|
5864
|
+
* @returns {TinyHtmlElement|TinyHtmlElement[]}
|
|
5621
5865
|
*/
|
|
5622
5866
|
setStyle(prop, value) {
|
|
5623
5867
|
return TinyHtml_TinyHtml.setStyle(this, prop, value);
|
|
@@ -5713,6 +5957,7 @@ class TinyHtml_TinyHtml {
|
|
|
5713
5957
|
*
|
|
5714
5958
|
* @param {TinyHtmlElement|TinyHtmlElement[]} el - A single element or an array of elements.
|
|
5715
5959
|
* @param {string|string[]} prop - A property name or an array of property names to remove.
|
|
5960
|
+
* @returns {TinyHtmlElement|TinyHtmlElement[]}
|
|
5716
5961
|
*/
|
|
5717
5962
|
static removeStyle(el, prop) {
|
|
5718
5963
|
TinyHtml_TinyHtml._preHtmlElems(el, 'removeStyle').forEach((elem) => {
|
|
@@ -5722,12 +5967,14 @@ class TinyHtml_TinyHtml {
|
|
|
5722
5967
|
}
|
|
5723
5968
|
} else elem.style.removeProperty(TinyHtml_TinyHtml.toStyleKc(prop));
|
|
5724
5969
|
});
|
|
5970
|
+
return el;
|
|
5725
5971
|
}
|
|
5726
5972
|
|
|
5727
5973
|
/**
|
|
5728
5974
|
* Removes one or more inline CSS properties from the given element(s).
|
|
5729
5975
|
*
|
|
5730
5976
|
* @param {string|string[]} prop - A property name or an array of property names to remove.
|
|
5977
|
+
* @returns {TinyHtmlElement|TinyHtmlElement[]}
|
|
5731
5978
|
*/
|
|
5732
5979
|
removeStyle(prop) {
|
|
5733
5980
|
return TinyHtml_TinyHtml.removeStyle(this, prop);
|
|
@@ -5742,6 +5989,7 @@ class TinyHtml_TinyHtml {
|
|
|
5742
5989
|
* @param {string} prop - The CSS property to toggle.
|
|
5743
5990
|
* @param {string} val1 - The first value (used as "current" check).
|
|
5744
5991
|
* @param {string} val2 - The second value (used as the "alternative").
|
|
5992
|
+
* @returns {TinyHtmlElement|TinyHtmlElement[]}
|
|
5745
5993
|
*/
|
|
5746
5994
|
static toggleStyle(el, prop, val1, val2) {
|
|
5747
5995
|
TinyHtml_TinyHtml._preHtmlElems(el, 'toggleStyle').forEach((elem) => {
|
|
@@ -5749,6 +5997,7 @@ class TinyHtml_TinyHtml {
|
|
|
5749
5997
|
const newVal = current === TinyHtml_TinyHtml.toStyleKc(val1) ? val2 : val1;
|
|
5750
5998
|
TinyHtml_TinyHtml.setStyle(elem, prop, newVal);
|
|
5751
5999
|
});
|
|
6000
|
+
return el;
|
|
5752
6001
|
}
|
|
5753
6002
|
|
|
5754
6003
|
/**
|
|
@@ -5759,6 +6008,7 @@ class TinyHtml_TinyHtml {
|
|
|
5759
6008
|
* @param {string} prop - The CSS property to toggle.
|
|
5760
6009
|
* @param {string} val1 - The first value (used as "current" check).
|
|
5761
6010
|
* @param {string} val2 - The second value (used as the "alternative").
|
|
6011
|
+
* @returns {TinyHtmlElement|TinyHtmlElement[]}
|
|
5762
6012
|
*/
|
|
5763
6013
|
toggleStyle(prop, val1, val2) {
|
|
5764
6014
|
return TinyHtml_TinyHtml.toggleStyle(this, prop, val1, val2);
|
|
@@ -5768,14 +6018,16 @@ class TinyHtml_TinyHtml {
|
|
|
5768
6018
|
* Removes all inline styles (`style` attribute) from the given element(s).
|
|
5769
6019
|
*
|
|
5770
6020
|
* @param {TinyElement|TinyElement[]} el - A single element or an array of elements.
|
|
6021
|
+
* @returns {TinyElement|TinyElement[]}
|
|
5771
6022
|
*/
|
|
5772
6023
|
static clearStyle(el) {
|
|
5773
6024
|
TinyHtml_TinyHtml._preElems(el, 'clearStyle').forEach((elem) => elem.removeAttribute('style'));
|
|
6025
|
+
return el;
|
|
5774
6026
|
}
|
|
5775
6027
|
|
|
5776
6028
|
/**
|
|
5777
6029
|
* Removes all inline styles (`style` attribute) from the given element(s).
|
|
5778
|
-
*
|
|
6030
|
+
* @returns {TinyElement|TinyElement[]}
|
|
5779
6031
|
*/
|
|
5780
6032
|
clearStyle() {
|
|
5781
6033
|
return TinyHtml_TinyHtml.clearStyle(this);
|
|
@@ -5787,14 +6039,17 @@ class TinyHtml_TinyHtml {
|
|
|
5787
6039
|
* Focus the element.
|
|
5788
6040
|
*
|
|
5789
6041
|
* @param {TinyHtmlElement} el - The element or a selector string.
|
|
6042
|
+
* @returns {TinyHtmlElement}
|
|
5790
6043
|
*/
|
|
5791
6044
|
static focus(el) {
|
|
5792
6045
|
const elem = TinyHtml_TinyHtml._preHtmlElem(el, 'focus');
|
|
5793
6046
|
elem.focus();
|
|
6047
|
+
return el;
|
|
5794
6048
|
}
|
|
5795
6049
|
|
|
5796
6050
|
/**
|
|
5797
6051
|
* Focus the element.
|
|
6052
|
+
* @returns {TinyHtmlElement}
|
|
5798
6053
|
*/
|
|
5799
6054
|
focus() {
|
|
5800
6055
|
return TinyHtml_TinyHtml.focus(this);
|
|
@@ -5804,19 +6059,46 @@ class TinyHtml_TinyHtml {
|
|
|
5804
6059
|
* Blur the element.
|
|
5805
6060
|
*
|
|
5806
6061
|
* @param {TinyHtmlElement} el - The element or a selector string.
|
|
6062
|
+
* @returns {TinyHtmlElement}
|
|
5807
6063
|
*/
|
|
5808
6064
|
static blur(el) {
|
|
5809
6065
|
const elem = TinyHtml_TinyHtml._preHtmlElem(el, 'blur');
|
|
5810
6066
|
elem.blur();
|
|
6067
|
+
return el;
|
|
5811
6068
|
}
|
|
5812
6069
|
|
|
5813
6070
|
/**
|
|
5814
6071
|
* Blur the element.
|
|
6072
|
+
* @returns {TinyHtmlElement}
|
|
5815
6073
|
*/
|
|
5816
6074
|
blur() {
|
|
5817
6075
|
return TinyHtml_TinyHtml.blur(this);
|
|
5818
6076
|
}
|
|
5819
6077
|
|
|
6078
|
+
/**
|
|
6079
|
+
* Interprets a value as a boolean `true` if it matches a common truthy representation.
|
|
6080
|
+
*
|
|
6081
|
+
* This method checks if the input is any of the common forms used to represent `true`,
|
|
6082
|
+
* such as the string `'true'`, `'1'`, `'on'`, the boolean `true`, or the number `1`.
|
|
6083
|
+
*
|
|
6084
|
+
* @param {string|boolean|number} [value] - The value to interpret as boolean.
|
|
6085
|
+
* @returns {boolean} `true` if the value represents a truthy state, otherwise `false`.
|
|
6086
|
+
*/
|
|
6087
|
+
static boolCheck(value) {
|
|
6088
|
+
if (
|
|
6089
|
+
typeof value !== 'undefined' &&
|
|
6090
|
+
(value === 'true' ||
|
|
6091
|
+
value === '1' ||
|
|
6092
|
+
value === true ||
|
|
6093
|
+
value === 'on' ||
|
|
6094
|
+
(typeof value === 'number' && value > 0))
|
|
6095
|
+
) {
|
|
6096
|
+
return true;
|
|
6097
|
+
} else {
|
|
6098
|
+
return false;
|
|
6099
|
+
}
|
|
6100
|
+
}
|
|
6101
|
+
|
|
5820
6102
|
//////////////////////////////////////////////////////////////////////
|
|
5821
6103
|
|
|
5822
6104
|
/**
|
|
@@ -5869,16 +6151,40 @@ class TinyHtml_TinyHtml {
|
|
|
5869
6151
|
return window.innerWidth || document.documentElement.clientWidth;
|
|
5870
6152
|
}
|
|
5871
6153
|
|
|
6154
|
+
/**
|
|
6155
|
+
* Checks if the page is currently scrolled to the very top.
|
|
6156
|
+
*
|
|
6157
|
+
* This method compares the current vertical scroll position with the total document height.
|
|
6158
|
+
* It's useful for detecting if the user has reached the top of the page.
|
|
6159
|
+
*
|
|
6160
|
+
* @returns {boolean} `true` if the page is scrolled to the top, otherwise `false`.
|
|
6161
|
+
*/
|
|
6162
|
+
static isPageTop() {
|
|
6163
|
+
return window.scrollY === 0;
|
|
6164
|
+
}
|
|
6165
|
+
|
|
6166
|
+
/**
|
|
6167
|
+
* Checks if the page is currently scrolled to the very bottom.
|
|
6168
|
+
*
|
|
6169
|
+
* This method uses the `scrollY` and `innerHeight` properties to determine if the
|
|
6170
|
+
* user has reached the end of the document.
|
|
6171
|
+
*
|
|
6172
|
+
* @returns {boolean} `true` if the page is scrolled to the bottom, otherwise `false`.
|
|
6173
|
+
*/
|
|
6174
|
+
static isPageBottom() {
|
|
6175
|
+
return window.innerHeight + window.scrollY >= document.body.offsetHeight;
|
|
6176
|
+
}
|
|
6177
|
+
|
|
5872
6178
|
/**
|
|
5873
6179
|
* Gets the width or height of an element based on the box model.
|
|
5874
|
-
* @param {
|
|
6180
|
+
* @param {TinyElementAndWinAndDoc} el - The element or window.
|
|
5875
6181
|
* @param {"width"|"height"} type - Dimension type.
|
|
5876
6182
|
* @param {"content"|"padding"|"border"|"margin"} [extra='content'] - Box model context.
|
|
5877
6183
|
* @returns {number} - Computed dimension.
|
|
5878
6184
|
* @throws {TypeError} If `type` or `extra` is not a string.
|
|
5879
6185
|
*/
|
|
5880
6186
|
static getDimension(el, type, extra = 'content') {
|
|
5881
|
-
const elem = TinyHtml_TinyHtml.
|
|
6187
|
+
const elem = TinyHtml_TinyHtml._preElemAndWinAndDoc(el, 'getDimension');
|
|
5882
6188
|
if (typeof type !== 'string') throw new TypeError('The type must be a string.');
|
|
5883
6189
|
if (typeof extra !== 'string') throw new TypeError('The extra must be a string.');
|
|
5884
6190
|
|
|
@@ -5966,17 +6272,20 @@ class TinyHtml_TinyHtml {
|
|
|
5966
6272
|
* @param {TinyHtmlElement} el - Target element.
|
|
5967
6273
|
* @param {string|number} value - Height value.
|
|
5968
6274
|
* @throws {TypeError} If `value` is neither a string nor number.
|
|
6275
|
+
* @returns {TinyHtmlElement}
|
|
5969
6276
|
*/
|
|
5970
6277
|
static setHeight(el, value) {
|
|
5971
6278
|
const elem = TinyHtml_TinyHtml._preHtmlElem(el, 'setHeight');
|
|
5972
6279
|
if (typeof value !== 'number' && typeof value !== 'string')
|
|
5973
6280
|
throw new TypeError('The value must be a string or number.');
|
|
5974
6281
|
elem.style.height = typeof value === 'number' ? `${value}px` : value;
|
|
6282
|
+
return el;
|
|
5975
6283
|
}
|
|
5976
6284
|
|
|
5977
6285
|
/**
|
|
5978
6286
|
* Sets the height of the element.
|
|
5979
6287
|
* @param {string|number} value - Height value.
|
|
6288
|
+
* @returns {TinyHtmlElement}
|
|
5980
6289
|
*/
|
|
5981
6290
|
setHeight(value) {
|
|
5982
6291
|
return TinyHtml_TinyHtml.setHeight(this, value);
|
|
@@ -5987,17 +6296,20 @@ class TinyHtml_TinyHtml {
|
|
|
5987
6296
|
* @param {TinyHtmlElement} el - Target element.
|
|
5988
6297
|
* @param {string|number} value - Width value.
|
|
5989
6298
|
* @throws {TypeError} If `value` is neither a string nor number.
|
|
6299
|
+
* @returns {TinyHtmlElement}
|
|
5990
6300
|
*/
|
|
5991
6301
|
static setWidth(el, value) {
|
|
5992
6302
|
const elem = TinyHtml_TinyHtml._preHtmlElem(el, 'setWidth');
|
|
5993
6303
|
if (typeof value !== 'number' && typeof value !== 'string')
|
|
5994
6304
|
throw new TypeError('The value must be a string or number.');
|
|
5995
6305
|
elem.style.width = typeof value === 'number' ? `${value}px` : value;
|
|
6306
|
+
return el;
|
|
5996
6307
|
}
|
|
5997
6308
|
|
|
5998
6309
|
/**
|
|
5999
6310
|
* Sets the width of the element.
|
|
6000
6311
|
* @param {string|number} value - Width value.
|
|
6312
|
+
* @returns {TinyHtmlElement}
|
|
6001
6313
|
*/
|
|
6002
6314
|
setWidth(value) {
|
|
6003
6315
|
return TinyHtml_TinyHtml.setWidth(this, value);
|
|
@@ -6005,11 +6317,11 @@ class TinyHtml_TinyHtml {
|
|
|
6005
6317
|
|
|
6006
6318
|
/**
|
|
6007
6319
|
* Returns content box height.
|
|
6008
|
-
* @param {
|
|
6320
|
+
* @param {TinyElementAndWinAndDoc} el - Target element.
|
|
6009
6321
|
* @returns {number}
|
|
6010
6322
|
*/
|
|
6011
6323
|
static height(el) {
|
|
6012
|
-
const elem = TinyHtml_TinyHtml.
|
|
6324
|
+
const elem = TinyHtml_TinyHtml._preElemAndWinAndDoc(el, 'height');
|
|
6013
6325
|
return TinyHtml_TinyHtml.getDimension(elem, 'height', 'content');
|
|
6014
6326
|
}
|
|
6015
6327
|
|
|
@@ -6023,11 +6335,11 @@ class TinyHtml_TinyHtml {
|
|
|
6023
6335
|
|
|
6024
6336
|
/**
|
|
6025
6337
|
* Returns content box width.
|
|
6026
|
-
* @param {
|
|
6338
|
+
* @param {TinyElementAndWinAndDoc} el - Target element.
|
|
6027
6339
|
* @returns {number}
|
|
6028
6340
|
*/
|
|
6029
6341
|
static width(el) {
|
|
6030
|
-
const elem = TinyHtml_TinyHtml.
|
|
6342
|
+
const elem = TinyHtml_TinyHtml._preElemAndWinAndDoc(el, 'width');
|
|
6031
6343
|
return TinyHtml_TinyHtml.getDimension(elem, 'width', 'content');
|
|
6032
6344
|
}
|
|
6033
6345
|
|
|
@@ -6041,11 +6353,11 @@ class TinyHtml_TinyHtml {
|
|
|
6041
6353
|
|
|
6042
6354
|
/**
|
|
6043
6355
|
* Returns padding box height.
|
|
6044
|
-
* @param {
|
|
6356
|
+
* @param {TinyElementAndWinAndDoc} el - Target element.
|
|
6045
6357
|
* @returns {number}
|
|
6046
6358
|
*/
|
|
6047
6359
|
static innerHeight(el) {
|
|
6048
|
-
const elem = TinyHtml_TinyHtml.
|
|
6360
|
+
const elem = TinyHtml_TinyHtml._preElemAndWinAndDoc(el, 'innerHeight');
|
|
6049
6361
|
return TinyHtml_TinyHtml.getDimension(elem, 'height', 'padding');
|
|
6050
6362
|
}
|
|
6051
6363
|
|
|
@@ -6059,11 +6371,11 @@ class TinyHtml_TinyHtml {
|
|
|
6059
6371
|
|
|
6060
6372
|
/**
|
|
6061
6373
|
* Returns padding box width.
|
|
6062
|
-
* @param {
|
|
6374
|
+
* @param {TinyElementAndWinAndDoc} el - Target element.
|
|
6063
6375
|
* @returns {number}
|
|
6064
6376
|
*/
|
|
6065
6377
|
static innerWidth(el) {
|
|
6066
|
-
const elem = TinyHtml_TinyHtml.
|
|
6378
|
+
const elem = TinyHtml_TinyHtml._preElemAndWinAndDoc(el, 'innerWidth');
|
|
6067
6379
|
return TinyHtml_TinyHtml.getDimension(elem, 'width', 'padding');
|
|
6068
6380
|
}
|
|
6069
6381
|
|
|
@@ -6077,14 +6389,14 @@ class TinyHtml_TinyHtml {
|
|
|
6077
6389
|
|
|
6078
6390
|
/**
|
|
6079
6391
|
* Returns outer height of the element, optionally including margin.
|
|
6080
|
-
* @param {
|
|
6392
|
+
* @param {TinyElementAndWinAndDoc} el - Target element.
|
|
6081
6393
|
* @param {boolean} [includeMargin=false] - Whether to include margin.
|
|
6082
6394
|
* @returns {number}
|
|
6083
6395
|
*/
|
|
6084
6396
|
static outerHeight(el, includeMargin = false) {
|
|
6085
6397
|
if (typeof includeMargin !== 'boolean')
|
|
6086
6398
|
throw new TypeError('The "includeMargin" must be a boolean.');
|
|
6087
|
-
const elem = TinyHtml_TinyHtml.
|
|
6399
|
+
const elem = TinyHtml_TinyHtml._preElemAndWinAndDoc(el, 'outerHeight');
|
|
6088
6400
|
return TinyHtml_TinyHtml.getDimension(elem, 'height', includeMargin ? 'margin' : 'border');
|
|
6089
6401
|
}
|
|
6090
6402
|
|
|
@@ -6099,14 +6411,14 @@ class TinyHtml_TinyHtml {
|
|
|
6099
6411
|
|
|
6100
6412
|
/**
|
|
6101
6413
|
* Returns outer width of the element, optionally including margin.
|
|
6102
|
-
* @param {
|
|
6414
|
+
* @param {TinyElementAndWinAndDoc} el - Target element.
|
|
6103
6415
|
* @param {boolean} [includeMargin=false] - Whether to include margin.
|
|
6104
6416
|
* @returns {number}
|
|
6105
6417
|
*/
|
|
6106
6418
|
static outerWidth(el, includeMargin = false) {
|
|
6107
6419
|
if (typeof includeMargin !== 'boolean')
|
|
6108
6420
|
throw new TypeError('The "includeMargin" must be a boolean.');
|
|
6109
|
-
const elem = TinyHtml_TinyHtml.
|
|
6421
|
+
const elem = TinyHtml_TinyHtml._preElemAndWinAndDoc(el, 'outerWidth');
|
|
6110
6422
|
return TinyHtml_TinyHtml.getDimension(elem, 'width', includeMargin ? 'margin' : 'border');
|
|
6111
6423
|
}
|
|
6112
6424
|
|
|
@@ -6279,6 +6591,7 @@ class TinyHtml_TinyHtml {
|
|
|
6279
6591
|
* Sets the vertical scroll position.
|
|
6280
6592
|
* @param {TinyElementAndWindow|TinyElementAndWindow[]} el - Element or window.
|
|
6281
6593
|
* @param {number} value - Scroll top value.
|
|
6594
|
+
* @returns {TinyElementAndWindow|TinyElementAndWindow[]}
|
|
6282
6595
|
*/
|
|
6283
6596
|
static setScrollTop(el, value) {
|
|
6284
6597
|
if (typeof value !== 'number') throw new TypeError('ScrollTop value must be a number.');
|
|
@@ -6292,11 +6605,13 @@ class TinyHtml_TinyHtml {
|
|
|
6292
6605
|
elem.scrollTop = value;
|
|
6293
6606
|
}
|
|
6294
6607
|
});
|
|
6608
|
+
return el;
|
|
6295
6609
|
}
|
|
6296
6610
|
|
|
6297
6611
|
/**
|
|
6298
6612
|
* Sets the vertical scroll position.
|
|
6299
6613
|
* @param {number} value - Scroll top value.
|
|
6614
|
+
* @returns {TinyElementAndWindow|TinyElementAndWindow[]}
|
|
6300
6615
|
*/
|
|
6301
6616
|
setScrollTop(value) {
|
|
6302
6617
|
return TinyHtml_TinyHtml.setScrollTop(this, value);
|
|
@@ -6306,6 +6621,7 @@ class TinyHtml_TinyHtml {
|
|
|
6306
6621
|
* Sets the horizontal scroll position.
|
|
6307
6622
|
* @param {TinyElementAndWindow|TinyElementAndWindow[]} el - Element or window.
|
|
6308
6623
|
* @param {number} value - Scroll left value.
|
|
6624
|
+
* @returns {TinyElementAndWindow|TinyElementAndWindow[]}
|
|
6309
6625
|
*/
|
|
6310
6626
|
static setScrollLeft(el, value) {
|
|
6311
6627
|
if (typeof value !== 'number') throw new TypeError('ScrollLeft value must be a number.');
|
|
@@ -6319,11 +6635,13 @@ class TinyHtml_TinyHtml {
|
|
|
6319
6635
|
elem.scrollLeft = value;
|
|
6320
6636
|
}
|
|
6321
6637
|
});
|
|
6638
|
+
return el;
|
|
6322
6639
|
}
|
|
6323
6640
|
|
|
6324
6641
|
/**
|
|
6325
6642
|
* Sets the horizontal scroll position.
|
|
6326
6643
|
* @param {number} value - Scroll left value.
|
|
6644
|
+
* @returns {TinyElementAndWindow|TinyElementAndWindow[]}
|
|
6327
6645
|
*/
|
|
6328
6646
|
setScrollLeft(value) {
|
|
6329
6647
|
return TinyHtml_TinyHtml.setScrollLeft(this, value);
|
|
@@ -6454,15 +6772,16 @@ class TinyHtml_TinyHtml {
|
|
|
6454
6772
|
|
|
6455
6773
|
/**
|
|
6456
6774
|
* Adds one or more CSS class names to the element.
|
|
6457
|
-
* @type {(el: TinyElement|TinyElement[], ...tokens: string[]) =>
|
|
6775
|
+
* @type {(el: TinyElement|TinyElement[], ...tokens: string[]) => (TinyElement|TinyElement[])} - One or more class names to add.
|
|
6458
6776
|
*/
|
|
6459
6777
|
static addClass(el, ...args) {
|
|
6460
6778
|
TinyHtml_TinyHtml._preElems(el, 'addClass').forEach((elem) => elem.classList.add(...args));
|
|
6779
|
+
return el;
|
|
6461
6780
|
}
|
|
6462
6781
|
|
|
6463
6782
|
/**
|
|
6464
6783
|
* Adds one or more CSS class names to the element.
|
|
6465
|
-
* @type {(...tokens: string[]) =>
|
|
6784
|
+
* @type {(...tokens: string[]) => (TinyElement|TinyElement[])} - One or more class names to add.
|
|
6466
6785
|
*/
|
|
6467
6786
|
addClass(...args) {
|
|
6468
6787
|
return TinyHtml_TinyHtml.addClass(this, ...args);
|
|
@@ -6470,15 +6789,16 @@ class TinyHtml_TinyHtml {
|
|
|
6470
6789
|
|
|
6471
6790
|
/**
|
|
6472
6791
|
* Removes one or more CSS class names from the element.
|
|
6473
|
-
* @type {(el: TinyElement|TinyElement[], ...tokens: string[]) =>
|
|
6792
|
+
* @type {(el: TinyElement|TinyElement[], ...tokens: string[]) => (TinyElement|TinyElement[])} - One or more class names to remove.
|
|
6474
6793
|
*/
|
|
6475
6794
|
static removeClass(el, ...args) {
|
|
6476
6795
|
TinyHtml_TinyHtml._preElems(el, 'removeClass').forEach((elem) => elem.classList.remove(...args));
|
|
6796
|
+
return el;
|
|
6477
6797
|
}
|
|
6478
6798
|
|
|
6479
6799
|
/**
|
|
6480
6800
|
* Removes one or more CSS class names from the element.
|
|
6481
|
-
* @type {(...tokens: string[]) =>
|
|
6801
|
+
* @type {(...tokens: string[]) => (TinyElement|TinyElement[])} - One or more class names to remove.
|
|
6482
6802
|
*/
|
|
6483
6803
|
removeClass(...args) {
|
|
6484
6804
|
return TinyHtml_TinyHtml.removeClass(this, ...args);
|
|
@@ -6688,15 +7008,18 @@ class TinyHtml_TinyHtml {
|
|
|
6688
7008
|
* Set text content of elements.
|
|
6689
7009
|
* @param {TinyElement|TinyElement[]} el
|
|
6690
7010
|
* @param {string} value
|
|
7011
|
+
* @returns {TinyElement|TinyElement[]}
|
|
6691
7012
|
*/
|
|
6692
7013
|
static setText(el, value) {
|
|
6693
7014
|
if (typeof value !== 'string') throw new Error('Value is not a valid string.');
|
|
6694
7015
|
TinyHtml_TinyHtml._preElems(el, 'setText').forEach((el) => (el.textContent = value));
|
|
7016
|
+
return el;
|
|
6695
7017
|
}
|
|
6696
7018
|
|
|
6697
7019
|
/**
|
|
6698
7020
|
* Set text content of the element.
|
|
6699
7021
|
* @param {string} value
|
|
7022
|
+
* @returns {TinyElement|TinyElement[]}
|
|
6700
7023
|
*/
|
|
6701
7024
|
setText(value) {
|
|
6702
7025
|
return TinyHtml_TinyHtml.setText(this, value);
|
|
@@ -6705,13 +7028,16 @@ class TinyHtml_TinyHtml {
|
|
|
6705
7028
|
/**
|
|
6706
7029
|
* Remove all child nodes from each element.
|
|
6707
7030
|
* @param {TinyElement|TinyElement[]} el
|
|
7031
|
+
* @returns {TinyElement|TinyElement[]}
|
|
6708
7032
|
*/
|
|
6709
7033
|
static empty(el) {
|
|
6710
7034
|
TinyHtml_TinyHtml._preElems(el, 'empty').forEach((el) => (el.textContent = ''));
|
|
7035
|
+
return el;
|
|
6711
7036
|
}
|
|
6712
7037
|
|
|
6713
7038
|
/**
|
|
6714
7039
|
* Remove all child nodes of the element.
|
|
7040
|
+
* @returns {TinyElement|TinyElement[]}
|
|
6715
7041
|
*/
|
|
6716
7042
|
empty() {
|
|
6717
7043
|
return TinyHtml_TinyHtml.empty(this);
|
|
@@ -6719,35 +7045,40 @@ class TinyHtml_TinyHtml {
|
|
|
6719
7045
|
|
|
6720
7046
|
/**
|
|
6721
7047
|
* Get the innerHTML of the element.
|
|
6722
|
-
* @param {TinyElement
|
|
7048
|
+
* @param {TinyElement} el
|
|
7049
|
+
* @param {GetHTMLOptions} [ops]
|
|
6723
7050
|
* @returns {string}
|
|
6724
7051
|
*/
|
|
6725
|
-
static html(el) {
|
|
7052
|
+
static html(el, ops) {
|
|
6726
7053
|
const elem = TinyHtml_TinyHtml._preElem(el, 'html');
|
|
6727
|
-
return elem.
|
|
7054
|
+
return elem.getHTML(ops);
|
|
6728
7055
|
}
|
|
6729
7056
|
|
|
6730
7057
|
/**
|
|
6731
7058
|
* Get the innerHTML of the element.
|
|
7059
|
+
* @param {GetHTMLOptions} [ops]
|
|
6732
7060
|
* @returns {string}
|
|
6733
7061
|
*/
|
|
6734
|
-
html() {
|
|
6735
|
-
return TinyHtml_TinyHtml.html(this);
|
|
7062
|
+
html(ops) {
|
|
7063
|
+
return TinyHtml_TinyHtml.html(this, ops);
|
|
6736
7064
|
}
|
|
6737
7065
|
|
|
6738
7066
|
/**
|
|
6739
7067
|
* Set the innerHTML of each element.
|
|
6740
7068
|
* @param {TinyElement|TinyElement[]} el
|
|
6741
7069
|
* @param {string} value
|
|
7070
|
+
* @returns {TinyElement|TinyElement[]}
|
|
6742
7071
|
*/
|
|
6743
7072
|
static setHtml(el, value) {
|
|
6744
7073
|
if (typeof value !== 'string') throw new Error('Value is not a valid string.');
|
|
6745
7074
|
TinyHtml_TinyHtml._preElems(el, 'setHtml').forEach((el) => (el.innerHTML = value));
|
|
7075
|
+
return el;
|
|
6746
7076
|
}
|
|
6747
7077
|
|
|
6748
7078
|
/**
|
|
6749
7079
|
* Set the innerHTML of the element.
|
|
6750
7080
|
* @param {string} value
|
|
7081
|
+
* @returns {TinyElement|TinyElement[]}
|
|
6751
7082
|
*/
|
|
6752
7083
|
setHtml(value) {
|
|
6753
7084
|
return TinyHtml_TinyHtml.setHtml(this, value);
|
|
@@ -6881,6 +7212,7 @@ class TinyHtml_TinyHtml {
|
|
|
6881
7212
|
* @param {TinyInputElement|TinyInputElement[]} el - Target element.
|
|
6882
7213
|
* @param {SetValueList|((el: InputElement, val: SetValueList) => SetValueList)} value - The value to assign or a function that returns it.
|
|
6883
7214
|
* @throws {Error} If the computed value is not a valid string or boolean.
|
|
7215
|
+
* @returns {TinyInputElement|TinyInputElement[]}
|
|
6884
7216
|
*/
|
|
6885
7217
|
static setVal(el, value) {
|
|
6886
7218
|
TinyHtml_TinyHtml._preInputElems(el, 'setVal').forEach((elem) => {
|
|
@@ -6920,6 +7252,7 @@ class TinyHtml_TinyHtml {
|
|
|
6920
7252
|
if (typeof valToSet === 'string') elem.value = valToSet;
|
|
6921
7253
|
}
|
|
6922
7254
|
});
|
|
7255
|
+
return el;
|
|
6923
7256
|
}
|
|
6924
7257
|
|
|
6925
7258
|
/**
|
|
@@ -6927,6 +7260,7 @@ class TinyHtml_TinyHtml {
|
|
|
6927
7260
|
* Accepts strings, numbers, booleans or arrays of these values, or a callback function that computes them.
|
|
6928
7261
|
*
|
|
6929
7262
|
* @param {SetValueList|((el: InputElement, val: SetValueList) => SetValueList)} value - The value to assign or a function that returns it.
|
|
7263
|
+
* @returns {TinyInputElement|TinyInputElement[]}
|
|
6930
7264
|
* @throws {Error} If the computed value is not a valid string or boolean.
|
|
6931
7265
|
*/
|
|
6932
7266
|
setVal(value) {
|
|
@@ -7196,6 +7530,7 @@ class TinyHtml_TinyHtml {
|
|
|
7196
7530
|
* @param {string} event - The event type (e.g. 'click', 'keydown').
|
|
7197
7531
|
* @param {EventRegistryHandle} handler - The callback function to run on event.
|
|
7198
7532
|
* @param {EventRegistryOptions} [options] - Optional event listener options.
|
|
7533
|
+
* @returns {TinyEventTarget|TinyEventTarget[]}
|
|
7199
7534
|
*/
|
|
7200
7535
|
static on(el, event, handler, options) {
|
|
7201
7536
|
if (typeof event !== 'string') throw new TypeError('The event name must be a string.');
|
|
@@ -7208,6 +7543,7 @@ class TinyHtml_TinyHtml {
|
|
|
7208
7543
|
if (!Array.isArray(events[event])) events[event] = [];
|
|
7209
7544
|
events[event].push({ handler, options });
|
|
7210
7545
|
});
|
|
7546
|
+
return el;
|
|
7211
7547
|
}
|
|
7212
7548
|
|
|
7213
7549
|
/**
|
|
@@ -7216,6 +7552,7 @@ class TinyHtml_TinyHtml {
|
|
|
7216
7552
|
* @param {string} event - The event type (e.g. 'click', 'keydown').
|
|
7217
7553
|
* @param {EventRegistryHandle} handler - The callback function to run on event.
|
|
7218
7554
|
* @param {EventRegistryOptions} [options] - Optional event listener options.
|
|
7555
|
+
* @returns {TinyEventTarget|TinyEventTarget[]}
|
|
7219
7556
|
*/
|
|
7220
7557
|
on(event, handler, options) {
|
|
7221
7558
|
return TinyHtml_TinyHtml.on(this, event, handler, options);
|
|
@@ -7228,6 +7565,7 @@ class TinyHtml_TinyHtml {
|
|
|
7228
7565
|
* @param {string} event - The event type (e.g. 'click', 'keydown').
|
|
7229
7566
|
* @param {EventRegistryHandle} handler - The callback function to run on event.
|
|
7230
7567
|
* @param {EventRegistryOptions} [options={}] - Optional event listener options.
|
|
7568
|
+
* @returns {TinyEventTarget|TinyEventTarget[]}
|
|
7231
7569
|
*/
|
|
7232
7570
|
static once(el, event, handler, options = {}) {
|
|
7233
7571
|
if (typeof event !== 'string') throw new TypeError('The event name must be a string.');
|
|
@@ -7245,6 +7583,7 @@ class TinyHtml_TinyHtml {
|
|
|
7245
7583
|
typeof options === 'boolean' ? options : { ...options, once: true },
|
|
7246
7584
|
);
|
|
7247
7585
|
});
|
|
7586
|
+
return el;
|
|
7248
7587
|
}
|
|
7249
7588
|
|
|
7250
7589
|
/**
|
|
@@ -7253,6 +7592,7 @@ class TinyHtml_TinyHtml {
|
|
|
7253
7592
|
* @param {string} event - The event type (e.g. 'click', 'keydown').
|
|
7254
7593
|
* @param {EventRegistryHandle} handler - The callback function to run on event.
|
|
7255
7594
|
* @param {EventRegistryOptions} [options={}] - Optional event listener options.
|
|
7595
|
+
* @returns {TinyEventTarget|TinyEventTarget[]}
|
|
7256
7596
|
*/
|
|
7257
7597
|
once(event, handler, options = {}) {
|
|
7258
7598
|
return TinyHtml_TinyHtml.once(this, event, handler, options);
|
|
@@ -7265,6 +7605,7 @@ class TinyHtml_TinyHtml {
|
|
|
7265
7605
|
* @param {string} event - The event type.
|
|
7266
7606
|
* @param {EventRegistryHandle} handler - The function originally bound to the event.
|
|
7267
7607
|
* @param {boolean|EventListenerOptions} [options] - Optional listener options.
|
|
7608
|
+
* @returns {TinyEventTarget|TinyEventTarget[]}
|
|
7268
7609
|
*/
|
|
7269
7610
|
static off(el, event, handler, options) {
|
|
7270
7611
|
if (typeof event !== 'string') throw new TypeError('The event name must be a string.');
|
|
@@ -7277,6 +7618,7 @@ class TinyHtml_TinyHtml {
|
|
|
7277
7618
|
if (events[event].length === 0) delete events[event];
|
|
7278
7619
|
}
|
|
7279
7620
|
});
|
|
7621
|
+
return el;
|
|
7280
7622
|
}
|
|
7281
7623
|
|
|
7282
7624
|
/**
|
|
@@ -7285,6 +7627,7 @@ class TinyHtml_TinyHtml {
|
|
|
7285
7627
|
* @param {string} event - The event type.
|
|
7286
7628
|
* @param {EventRegistryHandle} handler - The function originally bound to the event.
|
|
7287
7629
|
* @param {boolean|EventListenerOptions} [options] - Optional listener options.
|
|
7630
|
+
* @returns {TinyEventTarget|TinyEventTarget[]}
|
|
7288
7631
|
*/
|
|
7289
7632
|
off(event, handler, options) {
|
|
7290
7633
|
return TinyHtml_TinyHtml.off(this, event, handler, options);
|
|
@@ -7295,6 +7638,7 @@ class TinyHtml_TinyHtml {
|
|
|
7295
7638
|
*
|
|
7296
7639
|
* @param {TinyEventTarget|TinyEventTarget[]} el - The target element.
|
|
7297
7640
|
* @param {string} event - The event type to remove (e.g. 'click').
|
|
7641
|
+
* @returns {TinyEventTarget|TinyEventTarget[]}
|
|
7298
7642
|
*/
|
|
7299
7643
|
static offAll(el, event) {
|
|
7300
7644
|
if (typeof event !== 'string') throw new TypeError('The event name must be a string.');
|
|
@@ -7307,12 +7651,14 @@ class TinyHtml_TinyHtml {
|
|
|
7307
7651
|
delete events[event];
|
|
7308
7652
|
}
|
|
7309
7653
|
});
|
|
7654
|
+
return el;
|
|
7310
7655
|
}
|
|
7311
7656
|
|
|
7312
7657
|
/**
|
|
7313
7658
|
* Removes all event listeners of a specific type from the element.
|
|
7314
7659
|
*
|
|
7315
7660
|
* @param {string} event - The event type to remove (e.g. 'click').
|
|
7661
|
+
* @returns {TinyEventTarget|TinyEventTarget[]}
|
|
7316
7662
|
*/
|
|
7317
7663
|
offAll(event) {
|
|
7318
7664
|
return TinyHtml_TinyHtml.offAll(this, event);
|
|
@@ -7324,6 +7670,7 @@ class TinyHtml_TinyHtml {
|
|
|
7324
7670
|
* @param {TinyEventTarget|TinyEventTarget[]} el - The target element.
|
|
7325
7671
|
* @param {((handler: EventListenerOrEventListenerObject, event: string) => boolean)|null} [filterFn=null] -
|
|
7326
7672
|
* Optional filter function to selectively remove specific handlers.
|
|
7673
|
+
* @returns {TinyEventTarget|TinyEventTarget[]}
|
|
7327
7674
|
*/
|
|
7328
7675
|
static offAllTypes(el, filterFn = null) {
|
|
7329
7676
|
if (filterFn !== null && typeof filterFn !== 'function')
|
|
@@ -7342,6 +7689,7 @@ class TinyHtml_TinyHtml {
|
|
|
7342
7689
|
|
|
7343
7690
|
__eventRegistry.delete(elem);
|
|
7344
7691
|
});
|
|
7692
|
+
return el;
|
|
7345
7693
|
}
|
|
7346
7694
|
|
|
7347
7695
|
/**
|
|
@@ -7349,6 +7697,7 @@ class TinyHtml_TinyHtml {
|
|
|
7349
7697
|
*
|
|
7350
7698
|
* @param {((handler: EventListenerOrEventListenerObject, event: string) => boolean)|null} [filterFn=null] -
|
|
7351
7699
|
* Optional filter function to selectively remove specific handlers.
|
|
7700
|
+
* @returns {TinyEventTarget|TinyEventTarget[]}
|
|
7352
7701
|
*/
|
|
7353
7702
|
offAllTypes(filterFn = null) {
|
|
7354
7703
|
return TinyHtml_TinyHtml.offAllTypes(this, filterFn);
|
|
@@ -7360,6 +7709,7 @@ class TinyHtml_TinyHtml {
|
|
|
7360
7709
|
* @param {TinyEventTarget|TinyEventTarget[]} el - Target element where the event should be triggered.
|
|
7361
7710
|
* @param {string} event - Name of the event to trigger.
|
|
7362
7711
|
* @param {Event|CustomEvent|CustomEventInit} [payload] - Optional event object or data to pass.
|
|
7712
|
+
* @returns {TinyEventTarget|TinyEventTarget[]}
|
|
7363
7713
|
*/
|
|
7364
7714
|
static trigger(el, event, payload = {}) {
|
|
7365
7715
|
if (typeof event !== 'string') throw new TypeError('The event name must be a string.');
|
|
@@ -7375,6 +7725,7 @@ class TinyHtml_TinyHtml {
|
|
|
7375
7725
|
|
|
7376
7726
|
elem.dispatchEvent(evt);
|
|
7377
7727
|
});
|
|
7728
|
+
return el;
|
|
7378
7729
|
}
|
|
7379
7730
|
|
|
7380
7731
|
/**
|
|
@@ -7382,6 +7733,7 @@ class TinyHtml_TinyHtml {
|
|
|
7382
7733
|
*
|
|
7383
7734
|
* @param {string} event - Name of the event to trigger.
|
|
7384
7735
|
* @param {Event|CustomEvent|CustomEventInit} [payload] - Optional event object or data to pass.
|
|
7736
|
+
* @returns {TinyEventTarget|TinyEventTarget[]}
|
|
7385
7737
|
*/
|
|
7386
7738
|
trigger(event, payload = {}) {
|
|
7387
7739
|
return TinyHtml_TinyHtml.trigger(this, event, payload);
|
|
@@ -7424,6 +7776,7 @@ class TinyHtml_TinyHtml {
|
|
|
7424
7776
|
* @param {TinyElement|TinyElement[]} el
|
|
7425
7777
|
* @param {string} name
|
|
7426
7778
|
* @param {string|null} [value=null]
|
|
7779
|
+
* @returns {TinyElement|TinyElement[]}
|
|
7427
7780
|
*/
|
|
7428
7781
|
static setAttr(el, name, value = null) {
|
|
7429
7782
|
if (typeof name !== 'string') throw new TypeError('The "name" must be a string.');
|
|
@@ -7433,12 +7786,14 @@ class TinyHtml_TinyHtml {
|
|
|
7433
7786
|
if (value === null) elem.removeAttribute(name);
|
|
7434
7787
|
else elem.setAttribute(name, value);
|
|
7435
7788
|
});
|
|
7789
|
+
return el;
|
|
7436
7790
|
}
|
|
7437
7791
|
|
|
7438
7792
|
/**
|
|
7439
7793
|
* Set an attribute on an element.
|
|
7440
7794
|
* @param {string} name
|
|
7441
7795
|
* @param {string|null} [value=null]
|
|
7796
|
+
* @returns {TinyElement|TinyElement[]}
|
|
7442
7797
|
*/
|
|
7443
7798
|
setAttr(name, value) {
|
|
7444
7799
|
return TinyHtml_TinyHtml.setAttr(this, name, value);
|
|
@@ -7448,15 +7803,18 @@ class TinyHtml_TinyHtml {
|
|
|
7448
7803
|
* Remove attribute(s) from an element.
|
|
7449
7804
|
* @param {TinyElement|TinyElement[]} el
|
|
7450
7805
|
* @param {string} name Space-separated list of attributes.
|
|
7806
|
+
* @returns {TinyElement|TinyElement[]}
|
|
7451
7807
|
*/
|
|
7452
7808
|
static removeAttr(el, name) {
|
|
7453
7809
|
if (typeof name !== 'string') throw new TypeError('The "name" must be a string.');
|
|
7454
7810
|
TinyHtml_TinyHtml._preElems(el, 'removeAttr').forEach((elem) => elem.removeAttribute(name));
|
|
7811
|
+
return el;
|
|
7455
7812
|
}
|
|
7456
7813
|
|
|
7457
7814
|
/**
|
|
7458
7815
|
* Remove attribute(s) from an element.
|
|
7459
7816
|
* @param {string} name Space-separated list of attributes.
|
|
7817
|
+
* @returns {TinyElement|TinyElement[]}
|
|
7460
7818
|
*/
|
|
7461
7819
|
removeAttr(name) {
|
|
7462
7820
|
return TinyHtml_TinyHtml.removeAttr(this, name);
|
|
@@ -7511,6 +7869,7 @@ class TinyHtml_TinyHtml {
|
|
|
7511
7869
|
* Set a property on an element.
|
|
7512
7870
|
* @param {TinyElement|TinyElement[]} el
|
|
7513
7871
|
* @param {string} name
|
|
7872
|
+
* @returns {TinyElement|TinyElement[]}
|
|
7514
7873
|
*/
|
|
7515
7874
|
static addProp(el, name) {
|
|
7516
7875
|
if (typeof name !== 'string') throw new TypeError('The "name" must be a string.');
|
|
@@ -7520,11 +7879,13 @@ class TinyHtml_TinyHtml {
|
|
|
7520
7879
|
// @ts-ignore
|
|
7521
7880
|
elem[name] = true;
|
|
7522
7881
|
});
|
|
7882
|
+
return el;
|
|
7523
7883
|
}
|
|
7524
7884
|
|
|
7525
7885
|
/**
|
|
7526
7886
|
* Set a property on an element.
|
|
7527
7887
|
* @param {string} name
|
|
7888
|
+
* @returns {TinyElement|TinyElement[]}
|
|
7528
7889
|
*/
|
|
7529
7890
|
addProp(name) {
|
|
7530
7891
|
return TinyHtml_TinyHtml.addProp(this, name);
|
|
@@ -7534,6 +7895,7 @@ class TinyHtml_TinyHtml {
|
|
|
7534
7895
|
* Remove a property from an element.
|
|
7535
7896
|
* @param {TinyElement|TinyElement[]} el
|
|
7536
7897
|
* @param {string} name
|
|
7898
|
+
* @returns {TinyElement|TinyElement[]}
|
|
7537
7899
|
*/
|
|
7538
7900
|
static removeProp(el, name) {
|
|
7539
7901
|
if (typeof name !== 'string') throw new TypeError('The "name" must be a string.');
|
|
@@ -7543,11 +7905,13 @@ class TinyHtml_TinyHtml {
|
|
|
7543
7905
|
// @ts-ignore
|
|
7544
7906
|
elem[name] = false;
|
|
7545
7907
|
});
|
|
7908
|
+
return el;
|
|
7546
7909
|
}
|
|
7547
7910
|
|
|
7548
7911
|
/**
|
|
7549
7912
|
* Remove a property from an element.
|
|
7550
7913
|
* @param {string} name
|
|
7914
|
+
* @returns {TinyElement|TinyElement[]}
|
|
7551
7915
|
*/
|
|
7552
7916
|
removeProp(name) {
|
|
7553
7917
|
return TinyHtml_TinyHtml.removeProp(this, name);
|
|
@@ -7588,13 +7952,16 @@ class TinyHtml_TinyHtml {
|
|
|
7588
7952
|
/**
|
|
7589
7953
|
* Removes an element from the DOM.
|
|
7590
7954
|
* @param {TinyElement|TinyElement[]} el - The DOM element or selector to remove.
|
|
7955
|
+
* @returns {TinyElement|TinyElement[]}
|
|
7591
7956
|
*/
|
|
7592
7957
|
static remove(el) {
|
|
7593
7958
|
TinyHtml_TinyHtml._preElems(el, 'remove').forEach((elem) => elem.remove());
|
|
7959
|
+
return el;
|
|
7594
7960
|
}
|
|
7595
7961
|
|
|
7596
7962
|
/**
|
|
7597
7963
|
* Removes the element from the DOM.
|
|
7964
|
+
* @returns {TinyElement|TinyElement[]}
|
|
7598
7965
|
*/
|
|
7599
7966
|
remove() {
|
|
7600
7967
|
return TinyHtml_TinyHtml.remove(this);
|
|
@@ -7938,6 +8305,14 @@ class TinyHtml_TinyHtml {
|
|
|
7938
8305
|
*/
|
|
7939
8306
|
static isInViewport(el) {
|
|
7940
8307
|
const elem = TinyHtml_TinyHtml._preElem(el, 'isInViewport');
|
|
8308
|
+
if (
|
|
8309
|
+
!elem.checkVisibility({
|
|
8310
|
+
contentVisibilityAuto: false,
|
|
8311
|
+
opacityProperty: false,
|
|
8312
|
+
visibilityProperty: false,
|
|
8313
|
+
})
|
|
8314
|
+
)
|
|
8315
|
+
return false;
|
|
7941
8316
|
const elementTop = TinyHtml_TinyHtml.offset(elem).top;
|
|
7942
8317
|
const elementBottom = elementTop + TinyHtml_TinyHtml.outerHeight(elem);
|
|
7943
8318
|
|
|
@@ -7964,6 +8339,14 @@ class TinyHtml_TinyHtml {
|
|
|
7964
8339
|
*/
|
|
7965
8340
|
static isScrolledIntoView(el) {
|
|
7966
8341
|
const elem = TinyHtml_TinyHtml._preElem(el, 'isScrolledIntoView');
|
|
8342
|
+
if (
|
|
8343
|
+
!elem.checkVisibility({
|
|
8344
|
+
contentVisibilityAuto: false,
|
|
8345
|
+
opacityProperty: false,
|
|
8346
|
+
visibilityProperty: false,
|
|
8347
|
+
})
|
|
8348
|
+
)
|
|
8349
|
+
return false;
|
|
7967
8350
|
const docViewTop = TinyHtml_TinyHtml.scrollTop(window);
|
|
7968
8351
|
const docViewBottom = docViewTop + TinyHtml_TinyHtml.height(window);
|
|
7969
8352
|
|
|
@@ -7981,6 +8364,111 @@ class TinyHtml_TinyHtml {
|
|
|
7981
8364
|
isScrolledIntoView() {
|
|
7982
8365
|
return TinyHtml_TinyHtml.isScrolledIntoView(this);
|
|
7983
8366
|
}
|
|
8367
|
+
|
|
8368
|
+
/**
|
|
8369
|
+
* Checks if the given element is at least partially visible within the boundaries of a container.
|
|
8370
|
+
*
|
|
8371
|
+
* @param {TinyElement} el - The DOM element to check.
|
|
8372
|
+
* @param {TinyElement} cont - The container element acting as the viewport.
|
|
8373
|
+
* @returns {boolean} True if the element is partially visible within the container, false otherwise.
|
|
8374
|
+
*/
|
|
8375
|
+
static isInContainer(el, cont) {
|
|
8376
|
+
const elem = TinyHtml_TinyHtml._preElem(el, 'isInContainer');
|
|
8377
|
+
const container = TinyHtml_TinyHtml._preElem(cont, 'isInContainer');
|
|
8378
|
+
|
|
8379
|
+
if (
|
|
8380
|
+
!elem.checkVisibility({
|
|
8381
|
+
contentVisibilityAuto: false,
|
|
8382
|
+
opacityProperty: false,
|
|
8383
|
+
visibilityProperty: false,
|
|
8384
|
+
})
|
|
8385
|
+
)
|
|
8386
|
+
return false;
|
|
8387
|
+
const elemRect = elem.getBoundingClientRect();
|
|
8388
|
+
const containerRect = container.getBoundingClientRect();
|
|
8389
|
+
|
|
8390
|
+
const verticallyVisible =
|
|
8391
|
+
elemRect.bottom > containerRect.top && elemRect.top < containerRect.bottom;
|
|
8392
|
+
|
|
8393
|
+
const horizontallyVisible =
|
|
8394
|
+
elemRect.right > containerRect.left && elemRect.left < containerRect.right;
|
|
8395
|
+
|
|
8396
|
+
return verticallyVisible && horizontallyVisible;
|
|
8397
|
+
}
|
|
8398
|
+
|
|
8399
|
+
/**
|
|
8400
|
+
* Checks if the given element is at least partially visible within the boundaries of a container.
|
|
8401
|
+
*
|
|
8402
|
+
* @param {TinyElement} cont - The container element acting as the viewport.
|
|
8403
|
+
* @returns {boolean} True if the element is partially visible within the container, false otherwise.
|
|
8404
|
+
*/
|
|
8405
|
+
isInContainer(cont) {
|
|
8406
|
+
return TinyHtml_TinyHtml.isInContainer(this, cont);
|
|
8407
|
+
}
|
|
8408
|
+
|
|
8409
|
+
/**
|
|
8410
|
+
* Checks if the given element is fully visible within the boundaries of a container (top and bottom).
|
|
8411
|
+
*
|
|
8412
|
+
* @param {TinyElement} el - The DOM element to check.
|
|
8413
|
+
* @param {TinyElement} cont - The container element acting as the viewport.
|
|
8414
|
+
* @returns {boolean} True if the element is fully visible within the container, false otherwise.
|
|
8415
|
+
*/
|
|
8416
|
+
static isFullyInContainer(el, cont) {
|
|
8417
|
+
const elem = TinyHtml_TinyHtml._preElem(el, 'isScrolledIntoView');
|
|
8418
|
+
const container = TinyHtml_TinyHtml._preElem(cont, 'isInContainer');
|
|
8419
|
+
|
|
8420
|
+
if (
|
|
8421
|
+
!elem.checkVisibility({
|
|
8422
|
+
contentVisibilityAuto: false,
|
|
8423
|
+
opacityProperty: false,
|
|
8424
|
+
visibilityProperty: false,
|
|
8425
|
+
})
|
|
8426
|
+
)
|
|
8427
|
+
return false;
|
|
8428
|
+
const elemRect = elem.getBoundingClientRect();
|
|
8429
|
+
const containerRect = container.getBoundingClientRect();
|
|
8430
|
+
|
|
8431
|
+
const isFullyVisible =
|
|
8432
|
+
elemRect.top >= containerRect.top &&
|
|
8433
|
+
elemRect.bottom <= containerRect.bottom &&
|
|
8434
|
+
elemRect.left >= containerRect.left &&
|
|
8435
|
+
elemRect.right <= containerRect.right;
|
|
8436
|
+
|
|
8437
|
+
return isFullyVisible;
|
|
8438
|
+
}
|
|
8439
|
+
|
|
8440
|
+
/**
|
|
8441
|
+
* Checks if the given element is fully visible within the boundaries of a container (top and bottom).
|
|
8442
|
+
*
|
|
8443
|
+
* @param {TinyElement} cont - The container element acting as the viewport.
|
|
8444
|
+
* @returns {boolean} True if the element is fully visible within the container, false otherwise.
|
|
8445
|
+
*/
|
|
8446
|
+
isFullyInContainer(cont) {
|
|
8447
|
+
return TinyHtml_TinyHtml.isFullyInContainer(this, cont);
|
|
8448
|
+
}
|
|
8449
|
+
|
|
8450
|
+
/**
|
|
8451
|
+
* Checks if an element has scrollable content.
|
|
8452
|
+
*
|
|
8453
|
+
* @param {TinyElement} el - The DOM element to check.
|
|
8454
|
+
* @returns {{ v: boolean, h: boolean }} - True if scroll is needed in that direction.
|
|
8455
|
+
*/
|
|
8456
|
+
static hasScroll(el) {
|
|
8457
|
+
const elem = TinyHtml_TinyHtml._preElem(el, 'hasScroll');
|
|
8458
|
+
return {
|
|
8459
|
+
v: elem.scrollHeight > elem.clientHeight,
|
|
8460
|
+
h: elem.scrollWidth > elem.clientWidth,
|
|
8461
|
+
};
|
|
8462
|
+
}
|
|
8463
|
+
|
|
8464
|
+
/**
|
|
8465
|
+
* Checks if an element has scrollable content.
|
|
8466
|
+
*
|
|
8467
|
+
* @returns {{ v: boolean, h: boolean }} - True if scroll is needed in that direction.
|
|
8468
|
+
*/
|
|
8469
|
+
hasScroll() {
|
|
8470
|
+
return TinyHtml_TinyHtml.hasScroll(this);
|
|
8471
|
+
}
|
|
7984
8472
|
}
|
|
7985
8473
|
|
|
7986
8474
|
/* harmony default export */ const libs_TinyHtml = (TinyHtml_TinyHtml);
|