  * 
  */
 
+/**
+ * https://dom.spec.whatwg.org/#interface-characterdata
+ * 
+ * status: done
+ */
 public class CharacterData: Node, pCharacterData {
 
+  /**
+   * https://dom.spec.whatwg.org/#dom-characterdata-data
+   * 
+   * Cannot TreatNullAsEmptyString here because it would imply
+   * unwrapping the string every time <CharacterData>.data is accessed...
+   */
+  public var data: DOMString = ""
 
-  public var data: DOMString = ""
+  /**
+   * https://dom.spec.whatwg.org/#dom-characterdata-length
+   */
   public var length: ulong {
-    return ulong(data.characters.count)
+    return ulong(data.unicodeScalars.count)
   }
 
   static internal func _substringData(node: pCharacterData, _ offset: ulong, _ count: ulong) throws -> DOMString {

    // Step 10
    rangeCollection.forEach( {
      if ($0.startContainer as! Node === node as! Node && $0.startOffset > offset + count) {
        $0.setStart($0.startContainer!, $0.startOffset + ulong(str.characters.count) - count);
      }
    })

    // Step 11
    rangeCollection.forEach( {
      if ($0.endContainer as! Node === node as! Node && $0.endOffset > offset + count) {
        $0.setEnd($0.endContainer!, $0.endOffset + ulong(str.characters.count) - count);
      }
    })
  }

    MutationUtils.queueMutationRecord(node as! Node, "characterData", nil, nil, node.data, nil, nil, nil, nil)

    // Step 5, 6 and 7
    let index1 = node.data.unicodeScalars.startIndex.advancedBy(Int(offset))
    let index2 = node.data.unicodeScalars.startIndex.advancedBy(Int(offset + count))
    let preData = String(node.data.unicodeScalars[node.data.unicodeScalars.startIndex..<index1])
    let postData = String(node.data.unicodeScalars[index2..<node.data.unicodeScalars.endIndex])
    (node as! CharacterData).data = preData + str + postData

    let rangeCollection = ((node as! Node).ownerDocument as! Document).rangeCollection
