From 03dd4cd2b76f85cda43659265c76e7b77b7f2c96 Mon Sep 17 00:00:00 2001 From: kuangthree Date: Sat, 6 Jan 2024 22:29:14 +0800 Subject: [PATCH 1/3] =?UTF-8?q?=E6=9E=84=E9=80=A0=E5=99=A8=E5=92=8Cbuild?= =?UTF-8?q?=E8=99=9A=E6=96=B9=E6=B3=95=E5=88=86=E7=A6=BB=EF=BC=8C=E5=9C=A8?= =?UTF-8?q?create=E5=86=85=E8=B0=83=E7=94=A8build?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- noname/library/element/card.js | 4 ++-- noname/library/element/dialog.js | 2 +- noname/library/element/player.js | 5 ++--- noname/ui/index.js | 10 +++++++--- 4 files changed, 12 insertions(+), 9 deletions(-) diff --git a/noname/library/element/card.js b/noname/library/element/card.js index 6db575298..89f93ee33 100644 --- a/noname/library/element/card.js +++ b/noname/library/element/card.js @@ -12,14 +12,13 @@ export class Card extends HTMLDivElement { * @param {true} [noclick] */ // @ts-ignore - constructor(position, info, noclick) { + constructor(position) { /** * @type {this} */ // @ts-ignore const card = ui.create.div('.card', position); Object.setPrototypeOf(card, Card.prototype); - card.build(info, noclick); return card; } build(info, noclick) { @@ -28,6 +27,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 647ec8fb9..357b9c8c1 100644 --- a/noname/library/element/dialog.js +++ b/noname/library/element/dialog.js @@ -29,7 +29,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 eca04ba7b..44b6eec0a 100644 --- a/noname/library/element/player.js +++ b/noname/library/element/player.js @@ -8,17 +8,15 @@ 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) { /** * @type {this} */ // @ts-ignore const player = ui.create.div('.player', position); Object.setPrototypeOf(player, Player.prototype); - player.build(noclick); return player; } /** @@ -174,6 +172,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); From e66d6778e077a7a5ea09ba0c44a669fea3d7bfe1 Mon Sep 17 00:00:00 2001 From: kuangthree Date: Sun, 7 Jan 2024 14:51:07 +0800 Subject: [PATCH 2/3] =?UTF-8?q?=E4=BF=AE=E6=94=B9get.copy?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- noname/get/index.js | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/noname/get/index.js b/noname/get/index.js index 69d0e6009..c41c21fda 100644 --- a/noname/get/index.js +++ b/noname/get/index.js @@ -824,14 +824,8 @@ 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); From f9e44626c6c0af9309cce638b1ed396381e056a7 Mon Sep 17 00:00:00 2001 From: kuangthree Date: Sun, 7 Jan 2024 15:02:29 +0800 Subject: [PATCH 3/3] =?UTF-8?q?get.copy=E6=9E=84=E9=80=A0=E5=99=A8?= =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E5=8F=82=E6=95=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- noname/get/index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/noname/get/index.js b/noname/get/index.js index c41c21fda..1c74adaf7 100644 --- a/noname/get/index.js +++ b/noname/get/index.js @@ -828,7 +828,7 @@ export class Get extends Uninstantable { 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) {