CSSImportRule: supportsText property

فهرست فصل‌ها دانلود آرشیوناشر

MDN Web Docs · نسخهٔ df622a2a1c1e · CC BY-SA 2.5 و مجوز جداگانهٔ ناشر برای نمونه‌کد

{{APIRef("CSSOM")}}

The read-only **supportsText** property of the {{domxref("CSSImportRule")}} interface returns the supports condition specified by the {{cssxref("@import")}} at-rule.

Value

A string, or null.

Examples

The document's single stylesheet contains three {{cssxref("@import")}} rules. The first declaration imports a stylesheet if display: flex is supported. The second declaration imports a stylesheet if the :has selector is supported. The third declaration imports a stylesheet without a supports condition.

The supportsText property returns the import conditions associated with the at-rule.

css
@import "style1.css" supports(display: flex);
@import "style2.css" supports(selector(p:has(a)));
@import "style3.css";
js
const myRules = document.styleSheets[0].cssRules;
console.log(myRules[0].supportsText); // returns `"display: flex"`
console.log(myRules[1].supportsText); // returns `"selector(p:has(a))"`
console.log(myRules[2].supportsText); // returns `null`

Specifications

{{Specifications}}

Browser compatibility

{{Compat}}

See also