且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

Knockout.js数据绑定属性会导致HTML验证警告

更新时间:2022-10-26 20:53:48

它们是HTML 5自定义属性。尝试验证对照HTML 5规范,并且您应该在验证中得到确认。



但是,只要您认为合适,您可以使用自定义属性,尽管它可能违反了严格的HTML 4规范。

I'm using the HTML Validator firefox add-on and when I go to the home page of http://knockoutjs.com/, I get warnings about the data-bind attribute (for the Live Example):

Examples:

<select> proprietary attribute "data-bind"

<button> proprietary attribute "data-bind"

I also get errors regarding the data-bind attribute when submitting the URL at http://validator.w3.org/.

I know this html attribute is used by knockout.js to do some data binding, but can we conclude that this approach does not follow the HTML specification? Does knockout.js follow the spirit of valid HTML markup?

They are HTML 5 custom attributes. Try to validate against HTML 5 specs and you should get an ok on the validation.

But since long you have been able to use custom attributes as you see fit although it may have violated strict HTML 4 specs.