CSSImportRule: thuộc tính supportsText
Baseline
2024
Newly available
Since May 2024, this feature works across the latest devices and browser versions. This feature might not work in older devices or browsers.
Thuộc tính chỉ đọc supportsText của giao diện CSSImportRule trả về điều kiện supports được chỉ định bởi quy tắc điều kiện @import.
Giá trị
Một chuỗi, hoặc null.
Ví dụ
Bảng kiểu duy nhất của tài liệu chứa ba quy tắc @import. Khai báo đầu tiên nhập một bảng kiểu nếu display: flex được hỗ trợ. Khai báo thứ hai nhập một bảng kiểu nếu bộ chọn :has được hỗ trợ. Khai báo thứ ba nhập một bảng kiểu mà không có điều kiện supports.
Thuộc tính supportsText trả về các điều kiện nhập liên kết với quy tắc điều kiện.
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); // trả về `"display: flex"`
console.log(myRules[1].supportsText); // trả về `"selector(p:has(a))"`
console.log(myRules[2].supportsText); // trả về `null`
Đặc tả kỹ thuật
| Specification |
|---|
| CSS Object Model (CSSOM)> # dom-cssimportrule-supportstext> |