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

TypeError: value.match is not a function #612

Closed
smarlhens opened this issue Oct 11, 2022 · 3 comments · Fixed by #613
Closed

TypeError: value.match is not a function #612

smarlhens opened this issue Oct 11, 2022 · 3 comments · Fixed by #613
Assignees
Labels
bug Something isn't working high priority

Comments

@smarlhens
Copy link
Contributor

smarlhens commented Oct 11, 2022

Hi there 👋🏻

Describe the bug
I'm getting value as number instead of string in getTop (and I guess I can also get number in other functions like getLeft, getRight, etc).

It's maybe because property value I get from headlessui hidden fragment are not valid values (e.g. top: 1) but we should replace them by 0px I guess (that's what I get when I try using jsdom, all the values are replace with 0px).

Maybe we should return 0px if value is not a string as expected ?
Only 0 is a valid numeric for top and is equal to 0px;

References:

To Reproduce
Reproduction repo: https://github.com/smarlhens/happy-dom-value-match-is-not-a-function

Expected behavior
Not getting error in unit test 😄

Device:

  System:
    OS: Linux 5.15 Ubuntu 22.04.1 LTS 22.04.1 LTS (Jammy Jellyfish)
    CPU: (16) x64 11th Gen Intel(R) Core(TM) i7-11800H @ 2.30GHz
    Memory: 17.63 GB / 31.08 GB
    Container: Yes
    Shell: 5.8.1 - /usr/bin/zsh
  Binaries:
    Node: 16.17.1 - /usr/bin/node
    npm: 8.15.0 - /usr/bin/npm
  Browsers:
    Chrome: 106.0.5249.103
    Firefox: 105.0.2
  npmPackages:
    happy-dom: 7.5.6 => 7.5.6
    @vitejs/plugin-vue: 3.1.2 => 3.1.2 
    vite: 3.1.7 => 3.1.7 
    vitest: 0.24.1 => 0.24.1
@smarlhens smarlhens added the bug Something isn't working label Oct 11, 2022
@kalvenschraut
Copy link
Contributor

Receiving similar errors with value.trim is not a function.

image

It appears quasar is setting opacity to the number 0.2 which is then causing the error.

@capricorn86 capricorn86 self-assigned this Oct 11, 2022
capricorn86 added a commit that referenced this issue Oct 11, 2022
…han string to CSSStyleDeclaration properties, causing the property parser to crash.
capricorn86 added a commit that referenced this issue Oct 11, 2022
…h-is-not-a-function

#612@patch: Fixes issue related to sending in other types of values t…
@capricorn86
Copy link
Owner

Thank you for reporting @smarlhens and @kalvenschraut! 🙂

I have fixed the problem now.

You can read more about the release here:
https://github.com/capricorn86/happy-dom/releases/tag/v7.5.7

@capricorn86
Copy link
Owner

capricorn86 commented Oct 11, 2022

What should happen in the browser is the following (this is also what you will get in Happy DOM):

var element = document.createElement('div');
element.style.top = 2;
element.style.opacity = 0.2;

// Outputs "" (empty string)
console.log(element.style.top);

// Outputs "0.2"
console.log(element.style.opacity);

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working high priority
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants