weixin_39765209
weixin_39765209
2020-12-31 06:48

toggle: renamed toggle(showOrHide) to toggle(doShow)

To make it clear that passing true shows and passing false hides. Otherwise if you take showOrHide at its word, it would do nothing if you pass false and would call the regular toggle() if you pass true ;-)

该提问来源于开源项目:jquery/api.jquery.com

  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 复制链接分享
  • 邀请回答

15条回答

  • weixin_39677203 weixin_39677203 4月前

    Also I wasn't ignoring your "I liked it the old way" comment before the merge, I just didn't read it until after I had merged :frowning: sorry

    点赞 评论 复制链接分享
  • weixin_39639174 weixin_39639174 4月前

    Don't worry , I wasn't complaining :)

    点赞 评论 复制链接分享
  • weixin_39677203 weixin_39677203 4月前

    Thanks for the submission! Sorry that my showOrHide name was confusing to :smile:

    点赞 评论 复制链接分享
  • weixin_39765209 weixin_39765209 4月前

    Glad if it clears things up. At least for me ;-) setShown or doShow both sound like the initiation of a action, both are valid to me and I think both would make it more clear. I have no definite opinion on that, so setShown is ok for me if you prefer it.

    点赞 评论 复制链接分享
  • weixin_39677203 weixin_39677203 4月前

    :+1: Looks great, thanks for the quick update!

    点赞 评论 复制链接分享
  • weixin_39639174 weixin_39639174 4月前

    IMHO doShow doesn't clarify the concept. doShow seems tied to the show concept only, and not that passing false hides the elements.

    点赞 评论 复制链接分享
  • weixin_39646084 weixin_39646084 4月前

    How about makeVisible (or honestly, just leaving it as is).

    点赞 评论 复制链接分享
  • weixin_39677203 weixin_39677203 4月前

    I think the change to the description is important either way, what we call it doesn't matter that much to me, any name for that parameter is awkward.

    点赞 评论 复制链接分享
  • weixin_39639174 weixin_39639174 4月前

    :+1: for leaving it as is

    点赞 评论 复制链接分享
  • weixin_39765209 weixin_39765209 4月前

    The description should be changed in any case. Currently if you read it you might make the right guess, but you can't infer the meaning of the parameter from the documentation without reading the code snippet further down.

    I think all alternates are a little awkward, but faster to understand than showOrHide. makeVisible might be a little better, just show might be a little better, doShow, setShown are both better than the current version and could be used until someone has a even better idea.

    点赞 评论 复制链接分享
  • weixin_39677203 weixin_39677203 4月前

    I like it as you have it for now. Going to merge it.

    点赞 评论 复制链接分享
  • weixin_39640520 weixin_39640520 4月前

    Too bad. I agree that the description is better, but setShown is worse. It implies that the method will either show it or it won't, when what it really does is show it or hide it depending on its current state (hence the "showOrHide").

    点赞 评论 复制链接分享
  • weixin_39639174 weixin_39639174 4月前

    I agree with . It wasn't an urgent fix, so we could have discussed a bit more.

    点赞 评论 复制链接分享
  • weixin_39677203 weixin_39677203 4月前

    I know we went back and forth on it when documenting it originally I think 'showOrHide' was my own suggestion, and I'm seeing problems with it now. 'set shown' felt better. Let's talk it over in an issue and come back to it if needed? On Feb 17, 2015 1:55 PM, "Karl Swedberg" notifications.com wrote:

    Too bad. I agree that the description is better, but setShown is worse. It implies that the method will either show it or it won't, when what it really does is show it or hide it depending on its current state (hence the "showOrHide").

    — Reply to this email directly or view it on GitHub https://github.com/jquery/api.jquery.com/pull/654#issuecomment-74727181.

    点赞 评论 复制链接分享
  • weixin_39677203 weixin_39677203 4月前

    If you have opinions on what we should call this, please go to #655 - Thanks for the submission (and starting this discussion inadvertently)!

    点赞 评论 复制链接分享

相关推荐