Get the App
SLTechnology News&Howtos  ›  Development  › 

Functional example Test of jQuery.cssHooks

Shulou Source: shulou.com Published: 2022-06-01 13:07:51 10月01日 Update

This article mainly introduces the relevant knowledge of "functional instance testing of jQuery.cssHooks". The editor shows you the operation process through the actual case. The operation method is simple, fast and practical. I hope this "functional instance testing of jQuery.cssHooks" article can help you solve the problem.

Feature Testing (functional testing)

Before standardizing vendor-specific CSS attributes, first determine whether the browser supports standard attributes or variants with browser vendor prefixes. For example, check that the border-radius attribute is supported, and also check whether any variants of the attribute are members of the style object of the temporary element.

(function ($) {

Function styleSupport (prop) {

Var vendorProp, supportedProp

/ / capitalize first character of the prop to test vendor prefix

CapProp = prop.charAt (0) .toUpperCase () + prop.slice (1)

Prefixes = ["Moz", "Webkit", "O", "ms"]

Div = document.createElement ("div")

If (prop in div.style) {

/ / browser supports standard CSS property name

SupportedProp = prop

} else {

/ / otherwise test support for vendor-prefixed property names

For (var I = 0; I < prefixes.length; iTunes +) {

VendorProp = prefixes [I] + capProp

If (vendorProp in div.style) {

SupportedProp = vendorProp

Break

}

}

}

/ / avoid memory leak in IE

Div = null

/ / add property to $.support so it can be accessed elsewhere

$.support [prop] = supportedProp

Return supportedProp

}

/ / call the function, e.g. Testing for "border-radius" support:

StyleSupport ("borderRadius")

}) (jQuery)

This is the end of the content of "functional example testing of jQuery.cssHooks". Thank you for reading. If you want to know more about the industry, you can follow the industry information channel. The editor will update different knowledge points for you every day.

Tags: Functions tests attributes instances knowledge suppliers variants standards browsers industries supplies support inspection browsing differences utility elements content writing prefixes Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Apple macOS OPPO Reno Docker Shulou Technology