@@ -119,6 +119,41 @@ describe('parsePseudoToShape', () => {
119
119
border: 2px solid #fff;
120
120
border-top: 0;
121
121
border-left: 0;
122
+ }
123
+
124
+ .with-padding-button-wrapper {
125
+ background: #fff;
126
+ border-color: #d9d9d9;
127
+ border-style: solid;
128
+ border-width: 1.02px 1px 1px 0;
129
+ color: rgba(0, 0, 0, 0.85);
130
+ cursor: pointer;
131
+ display: inline-block;
132
+ font-size: 14px;
133
+ height: 32px;
134
+ line-height: 30px;
135
+ margin: 0;
136
+ padding: 0 15px;
137
+ position: relative;
138
+ }
139
+
140
+ .with-padding-button-wrapper:first-child {
141
+ border-left: 1px solid #d9d9d9;
142
+ border-radius: 2px 0 0 2px;
143
+ }
144
+
145
+ .with-padding-button-wrapper:not(:first-child):before {
146
+ background-color: red;
147
+ box-sizing: content-box;
148
+ content: "";
149
+ display: block;
150
+ height: 100%;
151
+ left: -1px;
152
+ padding: 1px 0;
153
+ position: absolute;
154
+ top: -1px;
155
+ width: 1px;
156
+ }
122
157
</style>
123
158
` ;
124
159
@@ -140,6 +175,11 @@ describe('parsePseudoToShape', () => {
140
175
<input type="checkbox" class="ant-checkbox-input" value="" checked="">
141
176
<span id="checkbox" class="ant-checkbox-inner"/>
142
177
</span>
178
+
179
+ <div >
180
+ <div id="no-padding" class="with-padding-button-wrapper">button</div>
181
+ <div id="with-padding" class="with-padding-button-wrapper">button</div>
182
+ </div>
143
183
</div>
144
184
` ;
145
185
document . body . append ( node ) ;
@@ -177,4 +217,16 @@ describe('parsePseudoToShape', () => {
177
217
178
218
expect ( checkbox . rotation ) . toBe ( - 45 ) ;
179
219
} ) ;
220
+
221
+ it ( '带 padding 的伪类宽高解析正常' , async ( ) => {
222
+ const node = document . getElementById ( 'with-padding' ) as HTMLDivElement ;
223
+ const shape = ( await parsePseudoToShape ( node , 'before' ) ) as Rectangle ;
224
+ const paddingBtn = shape . toSketchJSON ( ) ;
225
+
226
+ expect ( paddingBtn . frame . height ) . toBe ( 34 ) ;
227
+
228
+ const node1 = document . getElementById ( 'no-padding' ) as HTMLDivElement ;
229
+ const shape1 = await parsePseudoToShape ( node1 , 'before' ) ;
230
+ expect ( shape1 ) . toBeUndefined ( ) ;
231
+ } ) ;
180
232
} ) ;
0 commit comments