Uploaded image for project: 'Fluid Infusion'
  1. Fluid Infusion
  2. FLUID-5821

that.locate should return an empty element if the selector cannot be found...

    XMLWordPrintable

Details

    • Bug
    • Status: Closed
    • Blocker
    • Resolution: Fixed
    • None
    • 2.0
    • Framework
    • None

    Description

      If you run that.locate(selector) from a view component that does not have a matching selector, currently the entire container is returned. This means that a single typo in a selector can result in mistakenly operating on the entire container. In talking with Antranig about working around this problem, he proposed simply fixing it in FluidView.js.

      @bosmon, I hope you recall our "binder" that binds selectors to model values. the-t-in-rtf1 @ 2:57
      I am looking at it again, it fails completely if the selector isn't valid. 2:57
      if you recall, that.locate() with a bad selector returns the container. 2:58
      rather than null. 2:58
      I am wrapping the result in fluid.unwrap, which is undefined for selectors that don't exist and defined for selectors that are. 2:58
      Is using fluid.unwrap a reasonable way to detect this? 2:59
      in other words var element = that.locate(selector) 2:59
      and then if (fluid.unwrap(element)) 2:59
      as a test for validity. 2:59
      @Bosmon ^^^^ 3:01
       Bosmon
      the-t-in-rtf1 - you may instead just want to patch the DOM binder Bosmon @ 3:35	
      Bosmon
      The correct behaviour for it should be to return a 0-element jQuery in the case the selector matches nothing Bosmon @ 3:35
      We can patch this in a shortly upcoming infusion, this behaviour has annoyed us for far too long 3:36
       the-t-in-rtf1
      I would be very gratified to have that be my first pull request against infusion. the-t-in-rtf1 @ 3:39	
      the-t-in-rtf1
      I would start with the tests, but just to confirm that I'm on the right track, I would need to change behavior round about here:  https://github.com/fluid-project/infusion/blob/master/src/framework/core/js/FluidView.js#L170 the-t-in-rtf1 @ 3:47
      @Bosmon ^^^
      

      Attachments

        Issue Links

          Activity

            People

              antranig Antranig Basman
              the-t-in-rtf Tony Atkins
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: