mirror of
https://github.com/TiddlyWiki/TiddlyWiki5.git
synced 2026-04-25 01:54:41 +00:00
Move some deprecated functions to deprecated.js
This commit is contained in:
57
core/modules/utils/deprecated.js
Normal file
57
core/modules/utils/deprecated.js
Normal file
@@ -0,0 +1,57 @@
|
||||
/*\
|
||||
title: $:/core/modules/utils/deprecated.js
|
||||
type: application/javascript
|
||||
module-type: utils
|
||||
|
||||
Deprecated util functions
|
||||
|
||||
\*/
|
||||
|
||||
exports.logTable = data => console.table(data);
|
||||
|
||||
exports.repeat = (str,count) => str.repeat(count);
|
||||
|
||||
exports.startsWith = (str,search) => str.startsWith(search);
|
||||
|
||||
exports.endsWith = (str,search) => str.endsWith(search);
|
||||
|
||||
exports.trim = function(str) {
|
||||
if(typeof str === "string") {
|
||||
return str.trim();
|
||||
} else {
|
||||
return str;
|
||||
}
|
||||
};
|
||||
|
||||
exports.sign = Math.sign;
|
||||
|
||||
exports.strEndsWith = (str,ending,position) => str.endsWith(ending,position);
|
||||
|
||||
exports.stringifyNumber = num => num.toString();
|
||||
|
||||
exports.domContains = (a,b) => a.compareDocumentPosition(b) & 16;
|
||||
|
||||
// Use matches instead
|
||||
exports.domMatchesSelector = (node,selector) => node.matches(selector);
|
||||
|
||||
// Use element.classList.contains instead
|
||||
exports.hasClass = (el,className) => el.classList && el.classList.contains(className);
|
||||
|
||||
// Use element.classList.add instead
|
||||
exports.addClass = function(el,className) {
|
||||
el.classList && el.classList.add(className);
|
||||
};
|
||||
|
||||
// Use element.classList.remove instead
|
||||
exports.removeClass = function(el,className) {
|
||||
el.classList && el.classList.remove(className);
|
||||
};
|
||||
|
||||
// Use element.classList.toggle instead
|
||||
exports.toggleClass = function(el,className,status) {
|
||||
if(status === undefined) {
|
||||
el.classList && el.classList.toggle(className);
|
||||
} else {
|
||||
el.classList && el.classList.toggle(className, status);
|
||||
}
|
||||
};
|
||||
@@ -11,11 +11,6 @@ Various static DOM-related utility functions.
|
||||
|
||||
var Popup = require("$:/core/modules/utils/dom/popup.js");
|
||||
|
||||
// Deprecated: Use compareDocumentPosition instead
|
||||
exports.domContains = (a,b) => a.compareDocumentPosition(b) & 16;
|
||||
|
||||
// Deprecated: Use matches instead
|
||||
exports.domMatchesSelector = (node,selector) => node.matches(selector);
|
||||
|
||||
/*
|
||||
Select text in a an input or textarea (setSelectionRange crashes on certain input types)
|
||||
@@ -41,28 +36,6 @@ exports.removeChildren = function(node) {
|
||||
}
|
||||
};
|
||||
|
||||
// Deprecated: Use element.classList.contains instead
|
||||
exports.hasClass = (el,className) => el.classList && el.classList.contains(className);
|
||||
|
||||
// Deprecated: Use element.classList.add instead
|
||||
exports.addClass = function(el,className) {
|
||||
el.classList && el.classList.add(className);
|
||||
};
|
||||
|
||||
// Deprecated: Use element.classList.remove instead
|
||||
exports.removeClass = function(el,className) {
|
||||
el.classList && el.classList.remove(className);
|
||||
};
|
||||
|
||||
// Deprecated: Use element.classList.toggle instead
|
||||
exports.toggleClass = function(el,className,status) {
|
||||
if(status === undefined) {
|
||||
el.classList && el.classList.toggle(className);
|
||||
} else {
|
||||
el.classList && el.classList.toggle(className, status);
|
||||
}
|
||||
};
|
||||
|
||||
/*
|
||||
Get the first parent element that has scrollbars or use the body as fallback.
|
||||
*/
|
||||
|
||||
@@ -50,11 +50,6 @@ exports.warning = function(text) {
|
||||
exports.log(text,"brown/orange");
|
||||
};
|
||||
|
||||
/*
|
||||
Deprecated: Use console.table instead
|
||||
*/
|
||||
exports.logTable = data => console.table(data);
|
||||
|
||||
/*
|
||||
Return the integer represented by the str (string).
|
||||
Return the dflt (default) parameter if str is not a base-10 number.
|
||||
@@ -73,32 +68,6 @@ exports.replaceString = function(text,search,replace) {
|
||||
});
|
||||
};
|
||||
|
||||
/*
|
||||
Deprecated: Use str.repeat instead
|
||||
*/
|
||||
exports.repeat = (str,count) => str.repeat(count);
|
||||
|
||||
/*
|
||||
Deprecated: Use str.startsWith instead
|
||||
*/
|
||||
exports.startsWith = (str,search) => str.startsWith(search);
|
||||
|
||||
/*
|
||||
Deprecated: Use str.endsWith instead
|
||||
*/
|
||||
exports.endsWith = (str,search) => str.endsWith(search);
|
||||
|
||||
/*
|
||||
Deprecated: Use str.trim instead
|
||||
*/
|
||||
exports.trim = function(str) {
|
||||
if(typeof str === "string") {
|
||||
return str.trim();
|
||||
} else {
|
||||
return str;
|
||||
}
|
||||
};
|
||||
|
||||
exports.trimPrefix = function(str,unwanted) {
|
||||
if(typeof str === "string" && typeof unwanted === "string") {
|
||||
if(unwanted === "") {
|
||||
@@ -906,10 +875,6 @@ exports.tagToCssSelector = function(tagName) {
|
||||
});
|
||||
};
|
||||
|
||||
exports.sign = Math.sign;
|
||||
|
||||
exports.strEndsWith = (str,ending,position) => str.endsWith(ending,position);
|
||||
|
||||
/*
|
||||
Return system information useful for debugging
|
||||
*/
|
||||
@@ -936,9 +901,6 @@ exports.parseInt = function(str) {
|
||||
return parseInt(str,10) || 0;
|
||||
};
|
||||
|
||||
// Use Number.toString instead
|
||||
exports.stringifyNumber = num => num.toString();
|
||||
|
||||
exports.makeCompareFunction = function(type,options) {
|
||||
options = options || {};
|
||||
// set isCaseSensitive to true if not defined in options
|
||||
|
||||
Reference in New Issue
Block a user