// General Attr node fixes for Opera. (For testing only)
(function() {
    Attr.prototype.syncHolder = function() {
        if (typeof this.holder == "undefined") {
            this.holder = this.ownerDocument.createDocumentFragment();
            this.holder.textContent = this.textContent;
        }
    };
    Attr.prototype.__defineGetter__("value", function() {
        this.syncHolder();
        return this.textContent;
    });
    Attr.prototype.__defineSetter__("value", function(s) {
        this.holder = this.ownerDocument.createDocumentFragment();
        this.holder.textContent = s;
        this.textContent = s;
    });
    Attr.prototype.__defineGetter__("nodeValue", function() {
        return this.value;
    });
    Attr.prototype.__defineSetter__("nodeValue", function(s) {
        this.value = s;
    });
    Attr.prototype.__defineGetter__("firstChild", function() {
        this.syncHolder();
        return this.holder.firstChild;
    });
    Attr.prototype.__defineGetter__("lastChild", function() {
        this.syncHolder();
        return this.holder.firstChild;
    });
    Attr.prototype.hasChildNodes = function() {
        return this.textContent != "";
    };
    Attr.prototype.__defineGetter__("childNodes", function() {
        this.syncHolder();
        return this.holder.childNodes;
    });
    var Range_extractContents = Range.prototype.extractContents;
    var Range_toString = Range.prototype.toString;
    Range.prototype.toString = function() {
        if (this.startContainer instanceof Attr) {
            return this.startContainer.value;
        }
        return Range_toString.call(this);
    };
    Range.prototype.extractContents = function() {
        if (this.startContainer instanceof Attr) {
            var attr = this.startContainer;
            if (attr.value != "") {
                var doc = attr.ownerDocument;
                var frag = doc.createDocumentFragment();
                frag.appendChild(attr.firstChild);
                attr.value = "";
                return frag;
            }
            return null;
        } else {
            return Range_extractContents.call(this);
        }
    };
})()
