New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

HtmlElement::AttributeValue returns NULL ambiguity #247

Closed
GoogleCodeExporter opened this Issue Apr 6, 2015 · 1 comment

Comments

Projects
None yet
1 participant
@GoogleCodeExporter

GoogleCodeExporter commented Apr 6, 2015

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.

Original issue reported on code.google.com by sligocki@google.com on 21 Mar 2011 at 6:33

@GoogleCodeExporter

This comment has been minimized.

GoogleCodeExporter commented Apr 6, 2015

Documented both reasons to return NULL. Checked through call-sites and added 
tests in r721.

Original comment by sligocki@google.com on 25 May 2011 at 6:05

  • Changed state: Fixed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment