JSFiddle - React, Tailwind, and code Playground
HTML
<!DOCTYPE html>
<title>Custom Functions: ShadowDOM</title>
<link rel="help" href="https://drafts.csswg.org/css-mixins-1/#using-custom-functions">
<link rel="help" href="https://drafts.csswg.org/css-shadow-1/#css-tree-scoped-reference">
<script src="https://wpt.live/resources/testharness.js"></script>
<script src="https://wpt.live/resources/testharnessreport.js"></script>
<script src="https://wpt.live/css/css-mixins/resources/utils.js"></script>
<style>
@function --a() { result: 42px; }
</style>
<!--
Each element <div data-name="test case name"> represents a test.
Inside each such element (including all shadow trees), there must be
an element #target, with identical computed values for --actual and --expected.
-->
<div data-name="@function works inside shadow">
<template shadowrootmode=open>
<style>
@function --a() {
result: 10px;
}
#target {
--actual: --a();
--expected: 10px;
}
</style>
<div id=target></div>
</template>
</div>
<div data-name="Looking up document-global function">
<template shadowrootmode=open>
<style>
#target {
--actual: --a();
--expected: 42px;
}
</style>
<div id=target></div>
</template>
</div>
<div data-name="@function works inside nested shadow">
<template shadowrootmode=open>
<div>
<template shadowrootmode=open>
<style>
@function --a() {
result: 11px;
}
#target {
--actual: --a();
--expected: 11px;
}
</style>
<div id=target></div>
</template>
</div>
</template>
</div>
<div data-name="@function defined in outer shadow is visible">
<template shadowrootmode=open>
<style>
@function --a() {
result: 12px;
}
</style>
<div>
<template shadowrootmode=open>
<style>
#target {
...