1
0
mirror of https://github.com/Jermolene/TiddlyWiki5 synced 2024-11-30 05:19:57 +00:00

Fixed issue with fakedome TW_Node inheritence (#8195)

This commit is contained in:
Cameron Fischer 2024-05-21 17:02:37 -04:00 committed by GitHub
parent 0adc6024d1
commit 01b2e864c1
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 29 additions and 2 deletions

View File

@ -42,7 +42,7 @@ var TW_TextNode = function(text) {
this.textContent = text + "";
};
Object.setPrototypeOf(TW_TextNode,TW_Node.prototype);
Object.setPrototypeOf(TW_TextNode.prototype,TW_Node.prototype);
Object.defineProperty(TW_TextNode.prototype, "nodeType", {
get: function() {
@ -67,7 +67,7 @@ var TW_Element = function(tag,namespace) {
this.namespaceURI = namespace || "http://www.w3.org/1999/xhtml";
};
Object.setPrototypeOf(TW_Element,TW_Node.prototype);
Object.setPrototypeOf(TW_Element.prototype,TW_Node.prototype);
Object.defineProperty(TW_Element.prototype, "style", {
get: function() {

View File

@ -0,0 +1,27 @@
/*\
title: test-fakedom.js
type: application/javascript
tags: [[$:/tags/test-spec]]
Tests the fakedom that Tiddlywiki occasionally uses.
\*/
(function(){
/*jslint node: true, browser: true */
/*global $tw: false */
"use strict";
describe("fakedom tests", function() {
it("properly assigns nodeType based on DOM standards", function() {
// According to MDN, ELEMENT_NODE == 1 && TEXT_NODE == 3
// There are others, but currently they're not implemented in fakedom
expect($tw.fakeDocument.createElement("div").nodeType).toBe(1);
expect($tw.fakeDocument.createElement("div").ELEMENT_NODE).toBe(1);
expect($tw.fakeDocument.createTextNode("text").nodeType).toBe(3);
expect($tw.fakeDocument.createTextNode("text").TEXT_NODE).toBe(3);
});
});
})();