You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Is there a rationale for setting innerText rather than textContent in the setData function?
They do behave a bit differently -- I think textContent allows for more whitespace in some scenarios. However, it also appears to be faster than innerText which may be a nice added bonus to an already fast spreadsheet library.
Context: I had to dig pretty deep to understand why my tests were failing -- they rely on jsdom which is the go-to headless engine for jest. Turns out that jsdom doesn't support innerText due to its reliance on a layout engine. So for me, mocking innerText's setter and getter to be textContent helped make my tests pass. The workaround mentioned in the jsdom issue solved my problems, so I'd call this a suggestion rather than a request. But it could help users who write react applications and end up using a testing suite such as Jest that relies on jsdom.
The text was updated successfully, but these errors were encountered:
@hodeware here's what I used for innerText. There are still issues interacting with the table, but this works for reading what's in the table
// Taken from below (with a setter as well):// https://github.com/jsdom/jsdom/issues/1245#issuecomment-445848341// This is required for jspreadsheet tests to work appropriately, since// jspreadsheet's createCell function updates innerTextObject.defineProperty(global.Element.prototype,'innerText',{get(){returnthis.textContent},set(value){this.textContent=value},configurable: true,})
Is there a rationale for setting
innerText
rather thantextContent
in thesetData
function?They do behave a bit differently -- I think textContent allows for more whitespace in some scenarios. However, it also appears to be faster than
innerText
which may be a nice added bonus to an already fast spreadsheet library.Context: I had to dig pretty deep to understand why my tests were failing -- they rely on jsdom which is the go-to headless engine for jest. Turns out that jsdom doesn't support innerText due to its reliance on a layout engine. So for me, mocking
innerText
's setter and getter to betextContent
helped make my tests pass. The workaround mentioned in the jsdom issue solved my problems, so I'd call this a suggestion rather than a request. But it could help users who write react applications and end up using a testing suite such as Jest that relies on jsdom.The text was updated successfully, but these errors were encountered: