什么是DOMs元素属性的attribute.specified?

Hri*_*sto 6 attributes dom

我偶然发现了这样的事情......

function(element) {
  ...
  var attributes = element.attributes;
  for (var index = 0, length = attributes.length; index < length; index++) {
    var attribute = attributes[index];

    // what is ".specified"?
    if (attribute.specified) {
      ...
    }
  }
}
Run Code Online (Sandbox Code Playgroud)

我正在研究DOM元素的W3C规范,Element接口,我什么都看不到specified.

http://www.w3.org/TR/DOM-Level-3-Core/core.html#ID-745549614

什么attribute.specified意思?它代表什么?它在规格中的定义在哪里?

Mar*_*c B 3

<img src="kittens.jpg">。属性为src,其值为kittens.jpg。DOM 元素是通用定义。实际属性由实际使用的语言指定,例如 XML、HTML 等......

指定 = 该属性已分配有显式值。例如,指定了 src 属性,因为它被赋予了值 kittens.jpg,但是

<input type="checkbox" checked />
Run Code Online (Sandbox Code Playgroud)

已检查的属性已存在,但未指定。