jQuery causes Firefox box-sizing warnings

前端 未结 2 560
暗喜
暗喜 2021-01-17 08:20

I have the WebDeveloper extension and I got a CSS warning so I went to investigate it. The warning is 3 of the following:

Warning: Unknown property \'box-siz         


        
相关标签:
2条回答
  • 2021-01-17 09:03

    Options

    1. Use jQuery 1.7.2.
    2. Raise the issue with the jQuery team and hope for a fix (or provide one yourself).
    3. Use Firebug instead of WebDeveloper (which may or may not help).
    4. Ignore it.

    As long as the page renders correctly, I believe this is a warning you can safely ignore, even if you're building a website that strictly requires validating the CSS.

    The warnings should go away as soon as Firefox has full support for box-sizing (without requiring the -moz- prefix), but that won't happen until some version after Firefox 21.

    Background info

    The warning arises from the different syntaxes needed for certain CSS styles. To support all browsers, you generally have to specify all of the various syntaxes. Browsers will ignore the ones they don't recognize.

    In the case of box-sizing, Firefox requires the -moz- prefix, early versions of Safari Mobile and the Android browser require the -webkit- prefix, and other browsers require no prefix at all:

    -webkit-box-sizing: content-box;
       -moz-box-sizing: content-box;
            box-sizing: content-box;
    

    A similar issue arises when adding a linear gradient, in this case caused by the value rather than the property name:

    background-image: -webkit-linear-gradient(top, #444, #999);
    background-image:    -moz-linear-gradient(top, #444, #999);
    background-image:     -ms-linear-gradient(top, #444, #999);
    background-image:      -o-linear-gradient(top, #444, #999);
    background-image:         linear-gradient(top, #444, #999);
    

    When warnings arise from the different syntaxes used, it's typically a case of the validator or error console not being smart enough to recognize a real problem from a harmless one that's often unavoidable. And to be fair, it is in fact identified as a warning, not an error.

    Additional info

    Newer versions of jQuery make use of the box-sizing style for internal purposes. jQuery 1.8.0 only produces a single box-sizing warning, and jQuery 1.7.2 produces none.

    jQuery may be using it in a slightly-careless way -- without first testing if there's some type of support for it -- but without doing any actual harm. If so, if enough people complain about it to the jQuery team, the jQuery code could potentially be refactored to address this (at the cost of jQuery running a tiny bit slower).

    If the warning were about -moz-box-sizing rather than box-sizing, that would more likely suggest a possible bug with Firefox rather than a minor issue with jQuery.

    0 讨论(0)
  • 2021-01-17 09:03

    According to the jQuery folks this is a Firefox issue and they can't do anything about it. As of Firefox 27(beta) it is still happening. See: http://bugs.jquery.com/ticket/13569

    0 讨论(0)
提交回复
热议问题