Fix Entity widget not rendering its content without a refresh (#4776)

* Expose TEXT_NODE and ELEMENT_NODE constants

* Add failing test for initial rendering of entity widget

* Compute attributes when rendering
This commit is contained in:
ento
2020-07-31 08:25:15 +01:00
committed by GitHub
parent b32eb49d50
commit 222821804e
3 changed files with 41 additions and 2 deletions
+22 -2
View File
@@ -21,14 +21,32 @@ var bumpSequenceNumber = function(object) {
}
};
var TW_Node = function (){
throw TypeError("Illegal constructor");
};
Object.defineProperty(TW_Node.prototype, 'ELEMENT_NODE', {
get: function() {
return 1;
}
});
Object.defineProperty(TW_Node.prototype, 'TEXT_NODE', {
get: function() {
return 3;
}
});
var TW_TextNode = function(text) {
bumpSequenceNumber(this);
this.textContent = text + "";
};
TW_TextNode.prototype = Object.create(TW_Node.prototype);
Object.defineProperty(TW_TextNode.prototype, "nodeType", {
get: function() {
return 3;
return this.TEXT_NODE;
}
});
@@ -49,6 +67,8 @@ var TW_Element = function(tag,namespace) {
this.namespaceURI = namespace || "http://www.w3.org/1999/xhtml";
};
TW_Element.prototype = Object.create(TW_Node.prototype);
Object.defineProperty(TW_Element.prototype, "style", {
get: function() {
return this._style;
@@ -69,7 +89,7 @@ Object.defineProperty(TW_Element.prototype, "style", {
Object.defineProperty(TW_Element.prototype, "nodeType", {
get: function() {
return 1;
return this.ELEMENT_NODE;
}
});