125 lines
2.1 KiB
JavaScript
125 lines
2.1 KiB
JavaScript
/*
|
|
|
|
Copyright (c) 2020, 2023, The Unified Company.
|
|
|
|
This code is part of Unify.
|
|
|
|
This program is free software; you can redistribute it and/or modify
|
|
it under the terms of the ESA Software Community License - Strong Copyleft LICENSE,
|
|
as published by the ESA.
|
|
See the ESA Software Community License - Strong Copyleft LICENSE, for more details.
|
|
|
|
https://unifyjs.org
|
|
|
|
*/
|
|
|
|
|
|
class documentTool {
|
|
|
|
createElementDummy( object ) {
|
|
|
|
object.createElement = function( tag ){
|
|
|
|
var object = new Object();
|
|
|
|
object.tag = tag;
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
createElementNSDummy( object ) {
|
|
|
|
object.createElementNS = function( tag ){
|
|
|
|
var object = new Object();
|
|
|
|
object.tag = tag;
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
createDummyDomMethods( object ) {
|
|
|
|
this.createElementDummy( object );
|
|
|
|
this.createElementNSDummy( object );
|
|
|
|
}
|
|
|
|
bindCustomStyleTerms( object ) {
|
|
|
|
object.customStyleTerms = ["background", "width", "height", "flexDirection", "color", "border", "margin", "padding", "boxBackground"];
|
|
|
|
}
|
|
|
|
addBoxProperties( object ) {
|
|
|
|
for( var c = 0; c < object.customStyleTerms.length; c++ ) {
|
|
|
|
object.customStyleTerms[ object.customStyleTerms[ c ] ] = "";
|
|
|
|
object.customStyleTerms[ "box" + this.CamelCase( object.customStyleTerms[ c ] ) ] = "";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
createCustomStyleTerms( object ) {
|
|
|
|
this.bindCustomStyleTerms( object );
|
|
|
|
this.addBoxProperties( object );
|
|
|
|
}
|
|
|
|
getDocument(){
|
|
|
|
if( typeof document == "undefined" ){
|
|
|
|
var object = new Object();
|
|
|
|
this.createDummyDomMethods( object );
|
|
|
|
this.createCustomStyleTerms( object );
|
|
|
|
this.type = "server";
|
|
|
|
return object;
|
|
|
|
} else {
|
|
|
|
document.type = "client";
|
|
|
|
return document;
|
|
|
|
}
|
|
}
|
|
|
|
CamelCase( string ){
|
|
|
|
if( string ) {
|
|
|
|
string = string.toUpperCase();
|
|
|
|
string = string[0].toUpperCase() + string.slice(1,string.lenth).toLowerCase();
|
|
|
|
return string;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
var object = new documentTool();
|
|
|
|
export default object.getDocument();
|
|
|