Does jQuery support CSS4 selectors?

前端 未结 2 868
野性不改
野性不改 2021-01-18 02:33

Does jQuery or other JavaScript libraries support CSS4 selectors? Even browsers? How can I test them?

2条回答
  •  执笔经年
    2021-01-18 03:28

    The only level 4 selectors that jQuery supports at the moment are :has() and the extended version of :not() — and that's only because the spec took inspiration from jQuery itself, as jQuery had already implemented them years before the spec had its First Public Working Draft published in 2011.

    I wouldn't expect jQuery to implement any of the other features until the spec has stabilized (i.e. reached at least CR). You'll notice that :has() doesn't appear in the 2013 WD that you link to. That's because the subject selector, that does appear in the 2013 WD, was dropped in favor of :has() only a little over a year ago.

    So you can imagine why vendors are still holding back on implementing the spec. However, since at least one browser now partially implements Selectors 4, hopefully we won't have to wait much longer for other browsers to catch up.

    You can easily test them by just using them and seeing if they return the elements you expect.

提交回复
热议问题