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

Already on GitHub? Sign in to your account

renaming data-nobackbtn #672

Merged
2 commits merged into from Jan 11, 2011

Conversation

Projects
None yet
7 participants
Contributor

walkingeyerobot commented Dec 13, 2010

This patch would rename data-nobackbtn to data-backbtn.

When developing with jQuery mobile, in order to remove the back button from the header, the attribute data-nobackbtn must be set to 'true'. I've renamed this to data-backbtn because negative attributes can be confusing to developers. Positive attributes are much more clear.

I realize that this may break existing jQuery mobile apps, but I think changing this now will be better than leaving it in the future. I would also volunteer to write a patch that allows both data-backbtn and data-nobackbtn to be used in case backwards compatibility is a concern.

xavi- commented Dec 13, 2010

+1

I feel an API should be as concise and literate as possible. This change improves on both. Consider these use cases:

data-nobackbtn="true" // Roughly translates to "Yes no back button"
                      // A bit verbose IMO
data-nobackbtn="false" // Roughly translates to "No no back button"
                       // Double negatives are hard =(

VS

data-backbtn="true" // Roughly translates to "Yes back button"
                    // Very concise
data-backbtn="false" // Roughly translates to "No back button"
                     // Ahh that feels better

croy commented Dec 13, 2010

+1, for the same reason as Xavi.

federa commented Dec 13, 2010

I agree with Xavi, this is a much clearer implementation.

+1 for using only positively-named identifiers. This makes the interface much less confusing.

Martin Fowler famously made a mistake in Refactoring by confusing a negatively named variable. (Consolidate Confitional Expressions, 240) I think this serves as a canonical example of why we use positively named identifiers.

Agreed, negative identifiers only serve to confuse

Contributor

jblas commented Jan 7, 2011

I pulled these changes into my tree in an attempt to try and land this change, but noticed that after I had merged it, the headers with data-backbtn="false" in this sample:

http://jquerymobile.com/test/#docs/api/themes.html

all show up with back buttons. walkingeyerobot, can you or anyone else confirm that they see this too?

Contributor

jblas commented Jan 11, 2011

I landed this pull request but I had to tweak the logic that was changed when checking the data attribute. The 2 relevant checkins are:

8050fb0

8a70cdb

Thanks for the patch!!

This issue was closed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment