From 1ee2fd90475de47f648809ce717a1f35f9e66024 Mon Sep 17 00:00:00 2001 From: James Stuckey Weber Date: Fri, 4 Apr 2025 15:09:10 -0400 Subject: [PATCH 1/4] Allow anchor-size on margin and inset properties --- index.html | 32 ++++++++++++++++++++++++++++++++ public/anchor-size-extended.css | 12 ++++++++++++ src/cascade.ts | 1 + src/parse.ts | 15 ++++++++++----- src/polyfill.ts | 9 +++++---- src/syntax.ts | 8 ++++++++ 6 files changed, 68 insertions(+), 9 deletions(-) create mode 100644 public/anchor-size-extended.css diff --git a/index.html b/index.html index c092eb69..4afce661 100644 --- a/index.html +++ b/index.html @@ -32,6 +32,7 @@ + @@ -1242,6 +1243,37 @@

position-anchor: --anchor-scope; left: anchor(right); top: anchor(center); +} + +
+

+ + anchor-size() on margin and inset +

+
+
Anchor
+
Target
+
+

+ With polyfill applied: Target's margin is the height of the + anchor, and its right inset is the width of the anchor. +

+
#my-anchor-anchor-size-extended{
+  anchor-name: --my-anchor-size-extended;
+  resize: both;
+  overflow: hidden;
+}
+
+#my-target-anchor-size-extended{
+  position: absolute;
+  position-anchor: --my-anchor-size-extended;
+  right: anchor-size(width);
+  margin: anchor-size(height);
 }
+
+

+ + anchor-size() on margin and inset +

+
+
Anchor
+
Target
+
+

+ With polyfill applied: Target's margin is the height of the + anchor, and its right inset is the width of the anchor. +

+
#my-anchor-anchor-size-extended {
+  anchor-name: --my-anchor-size-extended;
+  resize: both;
+  overflow: hidden;
+}
+
+#my-target-anchor-size-extended {
+  position: absolute;
+  position-anchor: --my-anchor-size-extended;
+  right: anchor-size(width);
+  margin: anchor-size(height);
 }
@@ -1243,37 +1274,6 @@

position-anchor: --anchor-scope; left: anchor(right); top: anchor(center); -} -

-
-

- - anchor-size() on margin and inset -

-
-
Anchor
-
Target
-
-

- With polyfill applied: Target's margin is the height of the - anchor, and its right inset is the width of the anchor. -

-
#my-anchor-anchor-size-extended{
-  anchor-name: --my-anchor-size-extended;
-  resize: both;
-  overflow: hidden;
-}
-
-#my-target-anchor-size-extended{
-  position: absolute;
-  position-anchor: --my-anchor-size-extended;
-  right: anchor-size(width);
-  margin: anchor-size(height);
 }