My favorites | Sign in
Project Home Wiki Issues Source
New issue   Search
for
  Advanced search   Search tips   Subscriptions
Issue 247: HtmlElement::AttributeValue returns NULL ambiguity
1 person starred this issue and may be notified of changes. Back to list
Status:  Fixed
Owner:  sligocki@google.com
Closed:  May 2011
Cc:  ls...@google.com


Sign in to add a comment
 
Project Member Reported by sligocki@google.com, Mar 21, 2011
HtmlElement::AttributeValue("foo") returns NULL if either:
* no attribute "foo" exists or
* attribute foo has no value.

Code:
  // Look up attribute value by name.  NULL if no attribute exists.
  // Use this only if you don't intend to change the attribute value;
  // if you might change the attribute value, use FindAttribute instead
  // (this avoids a double lookup).
  const char* AttributeValue(HtmlName::Keyword name) const {
    const Attribute* attribute = FindAttribute(name);
    if (attribute != NULL) {
      return attribute->value();
    }
    return NULL;
  }

Code only documents no attribute case, so we should update that and make sure that we aren't depending upon the NULL meaning no attribute.
May 25, 2011
Project Member #1 sligocki@google.com
Documented both reasons to return NULL. Checked through call-sites and added tests in r721.
Status: Fixed
Sign in to add a comment

Powered by Google Project Hosting