Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: introduce devMode to support nodejs based unit testing #944

Merged
merged 1 commit into from
Dec 6, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions slick.grid.js
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,8 @@ if (typeof Slick === "undefined") {
maxSupportedCssHeight: 1000000000,
sanitizer: undefined, // sanitize function, built in basic sanitizer is: Slick.RegexSanitizer(dirtyHtml)
logSanitizedHtml: false, // log to console when sanitised - recommend true for testing of dev and production
shadowRoot: undefined
shadowRoot: undefined,
devMode: false
};

var columnDefaults = {
Expand Down Expand Up @@ -2116,6 +2117,11 @@ if (typeof Slick === "undefined") {
var i;
if (!stylesheet) {
var sheets = (options.shadowRoot || document).styleSheets;

if (options.devMode?.ownerNodeIndex >= 0) {
Copy link
Collaborator

@ghiscoding ghiscoding Dec 6, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@zewa666 so just to be clear, the devMode can be of type boolean or { ownerNodeIndex?: number; containerClientWidth?: number; }, is that correct? I'm asking because I'll have to backport this to the SlickGrid v5 with TypeScript and also into the next major major Slickgrid-Universal code

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

exactly right. I can also do the backport to v5(master?!) as mentioned above.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

alright I'm ok with the PR then as mentioned in paragraph below. So let me go ahead and merge the PR, I'll let you do the backport to v5, thanks for that.

I'll push new SlickGrid versions and other upstream libs probably in the weekend.
On all my upstream libs, I've now switched to GitHub Action workflows to publish releases because I wanted to publish on npm with --provenance and it's now much quicker to push releases, just hit start workflow :)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sounds great. getting late over here so I'll open the PR for v5 tomorrow. thx

sheets[options.devMode.ownerNodeIndex].ownerNode = _style;
}

for (i = 0; i < sheets.length; i++) {
if ((sheets[i].ownerNode || sheets[i].owningElement) == _style) {
stylesheet = sheets[i];
Expand Down Expand Up @@ -3765,7 +3771,7 @@ if (typeof Slick === "undefined") {
}

function getViewportWidth() {
viewportW = parseFloat(utils.innerSize(_container, 'width'));
viewportW = parseFloat(utils.innerSize(_container, 'width')) || options.devMode?.containerClientWidth;
}

function resizeCanvas() {
Expand Down