clientside/amplesdk — pull request #180 by AmicaNoctis (2012-12-17 01:55:43+00:00)
Title: Optionally expose getTextContent/setTextContent in Node class

## Summary

There is a textContent property, but it is useless. It always returns null and cannot react on modifications. In some cases it would be helpful to access it however, even if this access has to be performed via getter/setter methods. So it should be disabled by default, but possible to enable it easily at runtime, e. g. per ample.config()

A possible solution to this is enclosed in this pull request.

## Changes

Improved fNode_getTextContent, added fNode_setTextContent. Added configuration option to expose these methods in the Node class (default: don't expose).

## Example session

\> ample.documentElement.getTextContent();
TypeError: ample.documentElement.getTextContent is not a function

\> ample.config("enable-textcontent");
false

\> ample.config("enable-textcontent", true);

\> ample.documentElement.getTextContent();
"(Some string containing the concatenation of the values of all text nodes.)"

\> ample.config("enable-textcontent", false);

\> ample.documentElement.getTextContent();
TypeError: ample.documentElement.getTextContent is not a function