From 77dda4776566df4a1694d07daef263d032c1fdfa Mon Sep 17 00:00:00 2001 From: luojiahao Date: Fri, 2 Dec 2022 14:25:03 +0800 Subject: [PATCH] =?UTF-8?q?BUG:=20#149300=20-=20=E5=9B=BE=E6=A0=87?= =?UTF-8?q?=E5=AE=B9=E5=99=A8=E6=B7=BB=E5=8A=A0=E5=88=86=E9=A1=B5=E4=B8=8A?= =?UTF-8?q?=E9=99=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/grid-container/container.ts | 8 +++++++- .../grid-container/gaia-container-page.ts | 13 +++++++++++++ 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/src/components/grid-container/container.ts b/src/components/grid-container/container.ts index 7f6cc00..06a9dd4 100644 --- a/src/components/grid-container/container.ts +++ b/src/components/grid-container/container.ts @@ -744,7 +744,11 @@ export class GaiaContainer extends StarBaseElement { if (pagination < 0) return let page = this.pages[pagination] if (!page) { - page = this.addPage() + page = this.addPage()! + if (!page) { + console.error('Append child error!') + return + } } let proto = HTMLElement.prototype.appendChild let func @@ -1025,6 +1029,8 @@ export class GaiaContainer extends StarBaseElement { addPage(pages?: {page: HTMLElement; shadowPage: HTMLElement}) { const {page, shadowPage} = pages ?? this.pages.addPage() + if (!page || !shadowPage) return null + HTMLElement.prototype.appendChild.call(this, page) HTMLElement.prototype.appendChild.call(this, shadowPage) diff --git a/src/components/grid-container/gaia-container-page.ts b/src/components/grid-container/gaia-container-page.ts index 5c25b69..0844223 100644 --- a/src/components/grid-container/gaia-container-page.ts +++ b/src/components/grid-container/gaia-container-page.ts @@ -7,6 +7,8 @@ class GaiaContainerPage { _suspending: HTMLElement[] = [] _manager: GaiaContainer _shadowPagesMap: WeakMap = new WeakMap() + // 分页数量上限 + _limit: number = 15 _tail: HTMLElement | undefined _shadowTail: HTMLElement | undefined @@ -74,6 +76,13 @@ class GaiaContainerPage { } addPage = () => { + if (this._pages.length >= this._limit) { + console.info('The number of pages reaches the limit!') + return { + page: null, + shadowPage: null, + } + } const div = document.createElement('div') const pagination = `${this._pages.length}` div.className = `gaia-container-page` @@ -106,6 +115,10 @@ class GaiaContainerPage { addTail = () => { if (!this._tail || !this._shadowTail || this._tail.children.length) { const pages = this.addPage() + if (!pages.page || !pages.shadowPage) { + console.log('Can not add the page!') + return + } this._tail = pages.page this._suspending.push(this._tail) this._shadowTail = pages.shadowPage