Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Failed to set a named property on 'HTMLFormElement': Named property setter is not supported. #287

Open
thegoldenyou opened this issue Jun 29, 2021 · 0 comments

Comments

@thegoldenyou
Copy link

thegoldenyou commented Jun 29, 2021

版本

nice Validator 0.7.3

错误提示

jquery.validator.js:5. Uncaught TypeError: Failed to set a named property on 'HTMLFormElement': Named property setter is not supported.

报错行

s.$el[0].isValid=a?s.isFormValid():a

背景

之前的老代码,使用一直很正常,今天偶然发现 Validator 报错,最近未改动什么代码。

  • 同样的代码,Edge 浏览器下正常,Google下会报错
  • 同样的代码,生产环境运行正常,本地却会报错
提示信息
  • 表单中存在一个【id="isValid" name="isValid"】元素,将其注释掉后不再报错。
  • 最新版的 v1.1.5 也存在这个问题。报错行:me.isValid = me.$el[0].isValid = isValid ? me.isFormValid() : isValid;

看起来像属性名冲突了,但是正如我上面提到情况,之前一直都正常,没动过代码。

测试的临时处理方案

s.$el[0].isValid=a?s.isFormValid():a
我把这段代码捕获了一下(try-catch),发生异常后不做任何处理(没去设置 me.$el[0].isValid 这个属性),页面各项校验执行起来似乎也正常。
但不知道到这个问题怎么回事。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant