[Bug 16680] New: DOMTokenList assumes clean underlying string

https://www.w3.org/Bugs/Public/show_bug.cgi?id=16680

           Summary: DOMTokenList assumes clean underlying string
           Product: WebAppsWG
           Version: unspecified
          Platform: PC
        OS/Version: All
            Status: NEW
          Severity: normal
          Priority: P2
         Component: DOM
        AssignedTo: annevk@opera.com
        ReportedBy: w3c@marcosc.com
         QAContact: public-webapps-bugzilla@w3.org
                CC: mike@w3.org, www-dom@w3.org


The DOMTokenList assumes that the underlying string is always "clean" in that
it contains no spaces at the start and at the end or in between. However, in
the case of HTML's class attribute, the string can be "dirty", in that the
underlying string is derived from a the class attribute. Consider:

element.className = "   class1  \n class2 \t     class3    \t \n"

In order to get a clean string, the spec needs to define something the
following, so whitespace is removed:

//Splits the underlying string into a list of tokens
function splitUnderlyingString() {
  var underString = this.toString();
  var cleanString = underString.replace(/\s\s+/g, "\u0020").trim();
  return cleanString.split("\u0020");
}

Implementation already do the above, it seems. But the above is not clear in
the spec.

-- 
Configure bugmail: https://www.w3.org/Bugs/Public/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.

Received on Tuesday, 10 April 2012 10:46:17 UTC