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 when using html template element #33

Closed
mathieucivel opened this issue Apr 24, 2017 · 9 comments
Closed

TypeError when using html template element #33

mathieucivel opened this issue Apr 24, 2017 · 9 comments

Comments

@mathieucivel
Copy link

mathieucivel commented Apr 24, 2017

Hello,

I use Webpack 2 to import Tippy, just with an alias:

resolve: {
    alias: {
      'tippy$': 'tippy.js/dist/tippy.js',
    }
}

Then when creating a new Tippy instance:

import Tippy from 'tippy.js'
//...
new Tippy('.test', {
    html : document.querySelector('#test')  //It works fine with just the selector '#test'
})

I got the following error:

TypeError: Converting circular structure to JSON
    at Object.stringify (<anonymous>)
    at Tippy._applyIndividualSettings (webpack:///./~/tippy.js/dist/tippy.js?:2653:47)

It seems the HTMLElement is passed through the JSON.stringify method.

I have doubts on my way to import Tippy with webpack, but I'm running out of things to try..

@atomiks
Copy link
Owner

atomiks commented Apr 24, 2017

That error occurs when it tries to stringify itself: http://stackoverflow.com/questions/11616630/json-stringify-avoid-typeerror-converting-circular-structure-to-json

So I guess .test is the same element as #test?

Or.. maybe something else. I think I'll use a different method and do deep cloning to avoid problems

@mathieucivel
Copy link
Author

Well no, I added '.test' for the example but it was in fact a selector in a variable. Sorry I can't easily produce something for you to see the issue. Feel free to close this one :)

@atomiks
Copy link
Owner

atomiks commented Apr 24, 2017

For a second I was wondering how stringify handled HTML Elements being passed through, but it seems to work without errors here: https://codepen.io/anon/pen/aWmEZL

@mathieucivel
Copy link
Author

Yes I started to test this way, that's why I have doubts with my webpack config. I just can't find why. I tried to export/expose Tippy as a global, but with the same result (a string with the selector works, but not an element).

@atomiks
Copy link
Owner

atomiks commented Apr 24, 2017

Can you paste the full code here?

...And I just noticed from that pen that if a tooltip is flipped, clicking on it causes glitchy behavior instead of a smooth hide... more fixes to come

Edit: ^ was something I removed recently because I thought it was pointless, turns out it wasn't -_-

@atomiks
Copy link
Owner

atomiks commented Apr 24, 2017

I've switched to using Object.assign to clone the individual settings now since a deep copy isn't needed (popperOptions can't be defined in the HTML), maybe it will work now.

Check v0.8.2: https://github.com/atomiks/tippyjs/releases/tag/v0.8.2

@mathieucivel
Copy link
Author

Sorry I can't paste the code, so I made a new webpack projet. I can't reproduce the bug tough.. I'll try your last version thanks.

@atomiks
Copy link
Owner

atomiks commented Apr 24, 2017

Any luck?

@mathieucivel
Copy link
Author

Well it works for me now :) Thank you.

@atomiks atomiks closed this as completed Apr 25, 2017
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

No branches or pull requests

2 participants