fix(core): maxLength 默认值不再赋值 -1,修复浏览器 IndexSizeError
CI / test-parser (push) Successful in 9m26s
CI / test-core (push) Successful in 9m33s
CI / test-rest (push) Successful in 9m29s
CI / verify (18.x) (push) Successful in 9m50s
CI / verify (20.x) (push) Successful in 9m52s
CI / verify (24.x) (push) Successful in 9m45s
CI / test-parser (push) Successful in 9m26s
CI / test-core (push) Successful in 9m33s
CI / test-rest (push) Successful in 9m29s
CI / verify (18.x) (push) Successful in 9m50s
CI / verify (20.x) (push) Successful in 9m52s
CI / verify (24.x) (push) Successful in 9m45s
- textarea.maxLength 的 setter 不接受负值(-1 仅能通过不设置来 保持),显式赋 -1 在真实浏览器抛出 IndexSizeError - 改为仅当 maxLength > 0 时才设置属性 - 补防回归测试(mock setter 抛错 + 环境无关断言; jsdom 默认 maxLength 为 0,浏览器为 -1)
This commit is contained in:
+1
-1
@@ -206,7 +206,7 @@ export class MarkdownEditor {
|
||||
editorInner.appendChild(gutter);
|
||||
const textarea = document.createElement('textarea'); textarea.className = 'me-textarea';
|
||||
textarea.spellcheck = !!this.config.spellcheck; textarea.readOnly = !!this.config.readOnly;
|
||||
textarea.maxLength = this.config.maxLength && this.config.maxLength > 0 ? this.config.maxLength : -1;
|
||||
if (this.config.maxLength && this.config.maxLength > 0) textarea.maxLength = this.config.maxLength;
|
||||
textarea.style.tabSize = String(this.config.tabSize || 2);
|
||||
textarea.placeholder = this.config.placeholder || i18nT('placeholder');
|
||||
textarea.setAttribute('aria-label', i18nT('edit'));
|
||||
|
||||
Reference in New Issue
Block a user