Knockout.js data-bind attribute causes html valida

2019-09-18 01:44发布

问题:

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?

回答1:

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.