@@ -171,14 +171,19 @@ public function setAria($key, $value) {
171
171
}
172
172
173
173
protected function renderStartTag ($ tagName , $ closeTag = FALSE ) {
174
- $ rc = '< ' .$ tagName ;
174
+ $ attributes = $ this ->computeFinalAttributes ();
175
+ return \TgUtils \Html::renderStartTag ($ tagName , $ attributes , $ closeTag );
176
+ }
177
+
178
+ public function computeFinalAttributes () {
179
+ $ rc = array ();
175
180
176
- $ rc .= ' id=" ' . htmlspecialchars ( $ this ->component ->getId ()). ' " ' ;
181
+ $ rc[ ' id ' ] = $ this ->component ->getId ();
177
182
178
- // Render classes and styles first
183
+ // classes
179
184
$ classes = $ this ->getAttribute ('class ' , TRUE );
180
185
if (($ classes != NULL ) && (count ($ classes ) > 0 )) {
181
- $ rc .= ' class=" ' . htmlspecialchars ( trim ( implode ( ' ' , $ classes))). ' " ' ;
186
+ $ rc[ ' class ' ] = $ classes ;
182
187
}
183
188
184
189
$ styles = $ this ->getStyles (TRUE );
@@ -187,26 +192,19 @@ protected function renderStartTag($tagName, $closeTag = FALSE) {
187
192
foreach ($ styles AS $ name => $ value ) {
188
193
$ style .= ' ' .$ name .': ' .$ value .'; ' ;
189
194
}
190
- $ rc .= ' style=" ' . htmlspecialchars ( trim ($ style )). ' " ' ;
195
+ $ rc[ ' style ' ] = trim ($ style );
191
196
}
192
197
193
198
$ attributes = $ this ->getAttributes (TRUE );
194
- unset($ attributes ['class ' ]);
199
+ unset($ attributes ['class ' ], $ attributes [ ' style ' ], $ attributes [ ' id ' ] );
195
200
foreach ($ attributes AS $ name => $ value ) {
196
- if (is_array ($ value )) $ value = implode (' ' , $ value );
197
- if (is_numeric ($ value ) || is_string ($ value )) {
198
- $ rc .= ' ' .$ name .'=" ' .htmlspecialchars ($ value ).'" ' ;
199
- }
201
+ $ rc [$ name ] = $ value ;
200
202
}
201
-
202
- if ($ closeTag ) $ rc .= '/ ' ;
203
- $ rc .= '> ' ;
204
203
return $ rc ;
205
204
}
206
205
207
206
protected function renderEndTag ($ tagName ) {
208
- $ rc = '</ ' .$ tagName .'> ' ;
209
- return $ rc ;
207
+ return \TgUtils \Html::renderEndTag ($ tagName );
210
208
}
211
209
212
210
public function getParentFor ($ componentName ) {
0 commit comments