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

HTML data- attributes are ignored if they are set to false #413

Closed
wch opened this issue Sep 14, 2016 · 3 comments
Closed

HTML data- attributes are ignored if they are set to false #413

wch opened this issue Sep 14, 2016 · 3 comments
Assignees
Labels
[bug] low priority Bug or not a bug? Feature request Request for a new functionality
Milestone

Comments

@wch
Copy link

wch commented Sep 14, 2016

Setting a config option via a HTML data- attribute doesn't work if the value is "false". Example here, where it ignores data-prettify-enabled="false" but respects data-prettify-separator=",":
http://jsfiddle.net/winstonchang/hksvez8c/5/

I believe the problem is that the value is dropped from config_from_data when the value is falsy but non-zero:

if (!config_from_data[prop] && config_from_data[prop] !== 0) {
delete config_from_data[prop];
}

@IonDen
Copy link
Owner

IonDen commented Sep 15, 2016

Hi, maybe i need an additional check there. But now you can use something, that jquery will definitely convert correctly, like 1/0: http://jsfiddle.net/hksvez8c/6/

@IonDen IonDen added Feature request Request for a new functionality [bug] low priority Bug or not a bug? labels Sep 15, 2016
@IonDen IonDen self-assigned this Sep 15, 2016
@wch
Copy link
Author

wch commented Sep 15, 2016

Excellent, using "0" does work here. I'll use that workaround for now.

I should also note that using data-prettify-separator="" also doesn't work because it's a falsy value.

@IonDen IonDen added this to the 2.1.5 milestone Oct 12, 2016
@IonDen
Copy link
Owner

IonDen commented Dec 12, 2016

Should be fixed in 2.1.5

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[bug] low priority Bug or not a bug? Feature request Request for a new functionality
Projects
None yet
Development

No branches or pull requests

2 participants