nodejs fixes
This commit is contained in:
parent
dd5237e4ed
commit
7ed524517d
7 changed files with 32 additions and 15 deletions
|
|
@ -1,8 +1,10 @@
|
|||
{
|
||||
"name": "@0x2620/oxjs",
|
||||
"version": "1.0.0",
|
||||
"module": "min/Ox.esm.js",
|
||||
"main": "min/Ox/Ox.js",
|
||||
"module": "min/Ox/Ox.js",
|
||||
"browser": "min/Ox.js",
|
||||
"type": "module",
|
||||
"devDependencies": {
|
||||
"@rollup/plugin-node-resolve": "^16.0.3",
|
||||
"@rollup/plugin-terser": "^0.4.4",
|
||||
|
|
|
|||
|
|
@ -466,6 +466,7 @@ Ox.slice = Ox.toArray = function(collection, start, stop) {
|
|||
// value. Firefox 3.6 returns an array of undefined values if a string is passed
|
||||
// as value.
|
||||
if (
|
||||
typeof document !== 'undefined' && (
|
||||
Ox.slice([0]).length == 0
|
||||
|| Ox.slice('0')[0] === null
|
||||
|| Ox.slice('0')[0] === void 0
|
||||
|
|
@ -474,7 +475,7 @@ if (
|
|||
return Ox.slice(document.getElementsByTagName('a'));
|
||||
} catch (error) {}
|
||||
}())
|
||||
) {
|
||||
)) {
|
||||
// FIXME: remove toArray alias
|
||||
Ox.slice = Ox.toArray = function(collection, start, stop) {
|
||||
var args = stop === void 0 ? [start] : [start, stop],
|
||||
|
|
|
|||
|
|
@ -93,6 +93,7 @@ Ox.SHORT_MONTHS = Ox.MONTHS.map(function(val) {
|
|||
});
|
||||
//@ Ox.PATH <s> Path of Ox.js
|
||||
Ox.PATH = (function() {
|
||||
if (typeof document !== 'undefined') {
|
||||
// IE8 can't apply slice to NodeLists, see Ox.slice
|
||||
var index, regexp = /Ox\.js(\?.+|)$/,
|
||||
scripts = document.getElementsByTagName('script'), src;
|
||||
|
|
@ -102,6 +103,7 @@ Ox.PATH = (function() {
|
|||
return src.replace(regexp, '');
|
||||
}
|
||||
}
|
||||
}
|
||||
// FIXME: fix path detection
|
||||
return './source/';
|
||||
}());
|
||||
|
|
|
|||
|
|
@ -69,7 +69,6 @@ Ox.load = function() {
|
|||
callback(true);
|
||||
} else {
|
||||
let fn = Ox.noop
|
||||
console.log("!!", modules)
|
||||
if ('UI' in modules) {
|
||||
fn = function(callback) {
|
||||
var path = Ox.PATH + 'UI/jquery/jquery-1.7.1.min.js?' + Ox.VERSION;
|
||||
|
|
|
|||
|
|
@ -829,6 +829,13 @@ Ox.documentReady <function> Calls a callback function once the DOM is ready
|
|||
@*/
|
||||
Ox.documentReady = (function() {
|
||||
var callbacks = [];
|
||||
if (typeof document === 'undefined') {
|
||||
return function(callback) {
|
||||
callback();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
document.onreadystatechange = globalThis.onload = function() {
|
||||
if (document.readyState == 'complete') {
|
||||
callbacks.forEach(function(callback) {
|
||||
|
|
|
|||
|
|
@ -88,6 +88,10 @@ Ox.getAsync = function(urls, get, callback) {
|
|||
|
||||
(function() {
|
||||
|
||||
if (typeof document == 'undefined') {
|
||||
console.log("running in node, disable some things in Requets.js")
|
||||
return
|
||||
}
|
||||
var cache = {},
|
||||
head = document.head
|
||||
|| document.getElementsByTagName('head')[0]
|
||||
|
|
|
|||
|
|
@ -443,11 +443,13 @@ Ox.typeOf = function(value) {
|
|||
// Mobile Safari returns 'DOMWindow' for null and undefined
|
||||
// Firefox 30+ returns 'window' for window
|
||||
if (
|
||||
(typeof document != 'undefined') && (
|
||||
Ox.typeOf((function() { return arguments; }())) != 'arguments'
|
||||
|| Ox.typeOf(document.getElementsByTagName('a')) != 'nodelist'
|
||||
|| Ox.typeOf(null) != 'null'
|
||||
|| Ox.typeOf(window) != 'global'
|
||||
|| Ox.typeOf() != 'undefined'
|
||||
)
|
||||
) {
|
||||
Ox.typeOf = function(value) {
|
||||
var type = Object.prototype.toString.call(
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue