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: allow multiple classes to be set from windowClass #29

Merged
merged 2 commits into from
Mar 21, 2021
Merged

feat: allow multiple classes to be set from windowClass #29

merged 2 commits into from
Mar 21, 2021

Conversation

fschick
Copy link
Contributor

@fschick fschick commented Mar 19, 2021

PR Checklist

Please check if your PR fulfills the following requirements:

  • The commit message follows our guidelines: CONTRIBUTING.md#commit
  • Tests for the changes have been added (for bug fixes / features)
  • Docs have been added / updated (for bug fixes / features)

PR Type

What kind of change does this PR introduce?

[x] Bugfix
[x] Feature
[ ] Code style update (formatting, local variables)
[ ] Refactoring (no functional changes, no api changes)
[ ] Build related changes
[ ] CI related changes
[ ] Documentation content changes
[ ] Other... Please describe:

What is the current behavior?

When two classes added to DialogConfig.windowClass a
DOMException: Failed to execute 'add' on 'DOMTokenList': The token provided ('center dialog-lg') contains HTML space characters, which are not valid in tokens.
is thrown.

Issue Number: N/A

What is the new behavior?

All classes added to DialogConfig.windowClass will be added to host element.

Does this PR introduce a breaking change?

[ ] Yes
[x] No

Other information

@@ -74,7 +74,7 @@ export class DialogComponent implements OnInit, OnDestroy {
this.nodes.forEach(node => host.appendChild(node));

if (config.windowClass) {
host.classList.add(config.windowClass);
host.classList.add(...config.windowClass.split(/\s/).filter(x => x));
Copy link
Member

Choose a reason for hiding this comment

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

This will work in IE?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Well, no and yes. It doesn't work natively. IE isn't supported by project's browserlist. If you like it work's with IE change the browserlist and required ployfills should be added automatically. Still works (and tested via Virtual Machines) with Edge 18 (supported by the browserlist)

Copy link
Member

Choose a reason for hiding this comment

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

Let's change it to:

const classNames = config.windowClass.split(/\s/).filter(x => x);
classNames.forEach(name => host.classList.add(name))

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done, tested and pushed.

@NetanelBasal NetanelBasal merged commit 57a67bd into ngneat:master Mar 21, 2021
@fschick fschick deleted the allow-to-set-multple-classes-from-window-class branch March 21, 2021 19:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants