Skip to content

Commit d6f7507

Browse files
committed
Remove Property default-type() attribute
1 parent 1b474d5 commit d6f7507

4 files changed

Lines changed: 12 additions & 17 deletions

File tree

lib/CSS/Module.rakumod

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ multi method extend(
5757
:&coerce,
5858
:$prop-num = %!prop-names{$name.lc} // self.index.elems,
5959
Bool :$inherit = False,
60-
Str() :$default,
60+
Str() :$default is copy,
6161
|c,
6262
) {
6363
$name .= lc;
@@ -68,15 +68,13 @@ multi method extend(
6868
if &coerce {
6969
%!coerce{$name} = &coerce;
7070
with $default {
71-
my Pair $node = .&coerce;
72-
%metadata<default> = $node.value.Str;
73-
%metadata<default-type> = $node.key;
71+
$default = .&coerce.value.Str;
7472
}
7573
}
7674
else {
77-
%metadata<default> = $_ with $default;
7875
%!allow{$name}++;
7976
}
77+
%metadata<default> = $_ with $default;
8078
self!register-property: :$name, :%metadata;
8179
}
8280

lib/CSS/Module/Property.rakumod

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ class CSS::Module::Property is repr('CStruct') {
1717
has uint8 $.edge;
1818
has Str $.synopsis;
1919

20-
has Str $.default-type;
2120
has Str $.default;
2221

2322
has CArray[uint8] $.children;
@@ -26,7 +25,7 @@ class CSS::Module::Property is repr('CStruct') {
2625
has CArray[Str] $.edge-names;
2726

2827
submethod BUILD(:$!inherit = 0, :$!initial = 0, :$!box = 0) {}
29-
submethod TWEAK(:$enums, Str:D :$name!, :$!prop-num = (my uint8 $ = $enums{$name}), List :$children, List :$edges, Str :$edge, Str :$default, Str :$default-type, Str :$synopsis) {
28+
submethod TWEAK(:$enums, Str:D :$name!, :$!prop-num = (my uint8 $ = $enums{$name}), List :$children, List :$edges, Str :$edge, Str :$default, Str :$synopsis) {
3029
$!name := $name;
3130
$!synopsis := $_ with $synopsis;
3231
with $children {
@@ -39,7 +38,6 @@ class CSS::Module::Property is repr('CStruct') {
3938
}
4039
$!edge = $enums{$_} with $edge;
4140
$!default := $_ with $default;
42-
$!default-type := $_ with $default-type;
4341
}
4442

4543
multi method COERCE(%meta) { self.new: |%meta }

t/module-extensions.t

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@ is $module.name, 'CSS3', 'module.name';
2424
isa-ok $module.grammar, ::('CSS::Module::CSS3'), 'css3 grammar';
2525
isa-ok $module.actions, ::('CSS::Module::CSS3::Actions'), 'css3 actions';
2626
my $meta = $module.property-metadata;
27-
is-deeply $meta<-my-align>, {:inherit, :synopsis("<align> | justify")}, "'like' extension property";
28-
is-deeply $meta<-my-align2>, {:default["middle", [:keyw<middle>,]], :!inherit, :synopsis("left | middle | right")}, 'coerced extension property';
27+
is-deeply $meta<-my-align>, {:default("a nameless value that acts as 'left' if 'direction' is 'ltr', 'right' if 'direction' is 'rtl'"), :inherit, :synopsis("<align> | justify")}, "'like' extension property";
28+
is-deeply $meta<-my-align2>, {:default<middle>, :!inherit, :synopsis("left | middle | right")}, 'coerced extension property';
2929
is-deeply $meta<-my-anon>, {:!inherit,}, 'misc extension property';
3030
is-deeply $meta<-my-anon2>, {:inherit,}, 'misc extension property';
3131

t/module.t

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ is-deeply css1-module.colors<red>, [ 255, 0, 0 ], "colors";
2424
is css1-module.property-name(1), 'background-attachment';
2525
lives-ok { css1-module.index };
2626
lives-ok { css1-module.index[1] };
27-
is-deeply css1-module.index[1].default-type, 'keyw';
2827
is-deeply css1-module.index[1].default, 'scroll';
2928
is css1-module.property-name(6), 'border';
3029
is css1-module.property-number('border'), 6;
@@ -42,7 +41,7 @@ ok css21-prop<azimuth>:exists, 'css21 has azimuth';
4241
is-deeply css21-prop<border>, {:box, :children["border-width", "border-style", "border-color"], :edges["border-top", "border-right", "border-bottom", "border-left"], :!inherit, :synopsis("[ 'border-width' || 'border-style' || 'border-color' ]")}, 'css21 border';
4342
is-deeply css21-prop<border-style>, {:box, :edges[<border-top-style border-right-style border-bottom-style border-left-style>], :!inherit, :synopsis("<border-style>\{1,4}") }, 'css21 border-style';
4443

45-
is-deeply css21-prop<-xhtml-align>, {:inherit, :synopsis("<align> | justify")}, 'css21 alias property metadata';
44+
is-deeply css21-prop<-xhtml-align>, {:default("a nameless value that acts as 'left' if 'direction' is 'ltr', 'right' if 'direction' is 'rtl'"), :inherit, :synopsis("<align> | justify")}, 'css21 alias property metadata';
4645
is-deeply css21-module.parse-property('-xhtml-align', 'center' ), [{ :keyw<center> }, ], 'css21 alias property metadata';
4746

4847
is-deeply css21-module.colors<red>, [ 255, 0, 0 ], "colors";
@@ -56,7 +55,7 @@ is css3-module.name, 'CSS3', 'module.name';
5655
isa-ok css3-module.grammar, ::('CSS::Module::CSS3'), 'css3 grammar';
5756
isa-ok css3-module.actions, ::('CSS::Module::CSS3::Actions'), 'css3 actions';
5857
my \css3-prop = css3-module.property-metadata;
59-
is-deeply css3-prop<azimuth>, {:default["center", [{:keyw<center>},]], :inherit, :synopsis("<angle> | [ <direction> || <behind> ] | <delta>")}, 'css3 azimuth';
58+
is-deeply css3-prop<azimuth>, {:default<center>, :inherit, :synopsis("<angle> | [ <direction> || <behind> ] | <delta>")}, 'css3 azimuth';
6059
is-deeply css3-prop<border>, {:box, :children["border-width", "border-style", "border-color"], :edges["border-top", "border-right", "border-bottom", "border-left"], :!inherit, :synopsis("[ 'border-width' || 'border-style' || 'border-color' ]")}, 'css3 border';
6160
is-deeply css3-prop<border-style>, {:box, :edges[<border-top-style border-right-style border-bottom-style border-left-style>], :!inherit, :synopsis("<border-style>\{1,4}") }, 'css3 border-style';
6261

@@ -70,14 +69,14 @@ my \at-fontface-module = css3-module.sub-module<@font-face>;
7069
isa-ok at-fontface-module.grammar, ::('CSS::Module::CSS3::Fonts::AtFontFace'), '@font-face grammar';
7170
isa-ok at-fontface-module.actions, ::('CSS::Module::CSS3::Actions'), '@font-face actions';
7271
my \at-fontface-prop = at-fontface-module.property-metadata;
73-
is-deeply at-fontface-prop<font-style>, { :synopsis("normal | italic | oblique"), :!inherit, :default["normal", [{:keyw("normal")},]], }, '@font-face font-style';
72+
is-deeply at-fontface-prop<font-style>, { :synopsis("normal | italic | oblique"), :!inherit, :default<normal>, }, '@font-face font-style';
7473

7574
my \svg-module = CSS::Module::SVG.module;
7675
isa-ok svg-module.grammar, ::('CSS::Module::SVG'), 'svg grammar';
7776
isa-ok svg-module.actions, ::('CSS::Module::SVG::Actions'), 'svg actions';
7877
my \svg-prop = svg-module.property-metadata;
79-
is-deeply svg-prop<azimuth>, { :synopsis("<angle> | [ <direction> || <behind> ] | <delta>"), :inherit, :default["center", [{:keyw("center")},]], }, 'svg azimuth';
80-
is-deeply svg-prop<alignment-baseline>, { :synopsis("auto | baseline | before-edge | text-before-edge | middle | central | after-edge | text-after-edge | ideographic | alphabetic | hanging | mathematical"), :!inherit, :default["baseline", [{:keyw("baseline")},]], }, 'svg alignment-baseline';
81-
is-deeply svg-prop<font-style>, { :synopsis("normal | italic | oblique"), :inherit, :default["normal", [{:keyw("normal")},]], }, 'svg font-style';
78+
is-deeply svg-prop<azimuth>, { :synopsis("<angle> | [ <direction> || <behind> ] | <delta>"), :inherit, :default<center>, }, 'svg azimuth';
79+
is-deeply svg-prop<alignment-baseline>, { :synopsis("auto | baseline | before-edge | text-before-edge | middle | central | after-edge | text-after-edge | ideographic | alphabetic | hanging | mathematical"), :!inherit, :default<baseline>, }, 'svg alignment-baseline';
80+
is-deeply svg-prop<font-style>, { :synopsis("normal | italic | oblique"), :inherit, :default<normal>, }, 'svg font-style';
8281

8382
done-testing;

0 commit comments

Comments
 (0)