diff --git a/noname/get/index.js b/noname/get/index.js index 69d0e6009..1c74adaf7 100644 --- a/noname/get/index.js +++ b/noname/get/index.js @@ -824,17 +824,11 @@ export class Get extends Uninstantable { const constructor = obj.constructor; let target; if (!canTranverse[getType(obj)]) { - try { - // @ts-ignore - target = new constructor(obj); - } catch (error) { - if (obj instanceof HTMLElement) { - target = obj.cloneNode(true); // 不能cloneNode就寄吧,累了 - } else throw error - } + target = obj; + return target; } // @ts-ignore - else target = constructor ? new constructor() : Object.create(null); + else target = constructor ? new constructor(target) : Object.create(null); map.set(obj, target); if (obj instanceof Map) { diff --git a/noname/library/element/card.js b/noname/library/element/card.js index 1f7a9b13d..334de8d42 100644 --- a/noname/library/element/card.js +++ b/noname/library/element/card.js @@ -12,11 +12,11 @@ export class Card extends HTMLDivElement { * @param {true} [noclick] */ // @ts-ignore - constructor(position, info, noclick) { + constructor(position) { if (position instanceof Card) { const other = position; // @ts-ignore - [position, info, noclick] = other._args; + [position] = other._args; } /** * @type {this} @@ -24,9 +24,8 @@ export class Card extends HTMLDivElement { // @ts-ignore const card = ui.create.div('.card', position); Object.setPrototypeOf(card, Card.prototype); - card.build(info, noclick); // @ts-ignore - card._args = [position, info, noclick]; + card._args = [position]; return card; } build(info, noclick) { @@ -35,6 +34,7 @@ export class Card extends HTMLDivElement { card.buildIntro(noclick); card.buildProperty(); card.buildEventListener(info); + return this; } buildEventListener(info) { let card = this; diff --git a/noname/library/element/dialog.js b/noname/library/element/dialog.js index df5830db1..ed819d971 100644 --- a/noname/library/element/dialog.js +++ b/noname/library/element/dialog.js @@ -35,7 +35,7 @@ export class Dialog extends HTMLDivElement { else if (argument == 'noforcebutton') noForceButton = true; else dialog.add(argument); }); - if (!hidden) dialog.open(); + //if (!hidden) dialog.open(); if (!lib.config.touchscreen) dialog.contentContainer.onscroll = ui.update; if (!noTouchScroll) { dialog.contentContainer.ontouchstart = ui.click.dialogtouchStart; diff --git a/noname/library/element/player.js b/noname/library/element/player.js index 55dc6725f..6c1c0b604 100644 --- a/noname/library/element/player.js +++ b/noname/library/element/player.js @@ -8,24 +8,22 @@ import { UI as ui } from '../../ui/index.js'; export class Player extends HTMLDivElement { /** * @param {HTMLDivElement|DocumentFragment} [position] - * @param {true} [noclick] */ // @ts-ignore - constructor(position, noclick) { + + constructor(position) { if (position instanceof Player) { const other = position; - [position, noclick] = other._args; + [position] = other._args; } - /** * @type {this} */ // @ts-ignore const player = ui.create.div('.player', position); Object.setPrototypeOf(player, Player.prototype); - player.build(noclick); // @ts-ignore - player._args = [position, noclick]; + player._args = [position]; return player; } /** @@ -181,6 +179,7 @@ export class Player extends HTMLDivElement { player.buildProperty(); player.buildExtra(); player.buildEventListener(noclick); + return this; } buildNode() { let player = this; diff --git a/noname/ui/index.js b/noname/ui/index.js index e42192c94..744dd56c7 100644 --- a/noname/ui/index.js +++ b/noname/ui/index.js @@ -8655,7 +8655,11 @@ class Create extends Uninstantable { return dialog; } static dialog() { - return new lib.element.Dialog(...arguments); + let dialog = new lib.element.Dialog(...arguments); + if(!Array.from(arguments).includes('hidden')){ + dialog.open(); + } + return dialog; } static line2() { var node = ui.create.line.apply(this, arguments); @@ -9898,7 +9902,7 @@ class Create extends Uninstantable { dialog.buttons.add(next.firstChild); } } - static player(position, noclick) { return new lib.element.Player(position, noclick) } + static player(position, noclick) { return new lib.element.Player(position).build(noclick); } static connectPlayers(ip) { ui.updateConnectPlayerPositions(); game.connectPlayers = []; @@ -10047,7 +10051,7 @@ class Create extends Uninstantable { // ui.updatehl(); } } - static card(position, info, noclick) { return new lib.element.Card(position, info, noclick)} + static card(position, info, noclick) { return new lib.element.Card(position).build(info, noclick);} static cardsAsync() { if (lib.onfree) { _status.waitingForCards = Array.from(arguments);