File tree Expand file tree Collapse file tree 1 file changed +13
-4
lines changed
modules/custom/wxt_ext/wxt_ext_webform/js Expand file tree Collapse file tree 1 file changed +13
-4
lines changed Original file line number Diff line number Diff line change 2525 function isLegendRequired ( legend ) {
2626 return ! ! legend . querySelector ( 'span.js-form-required' ) ;
2727 }
28- function ensureAtEnd ( el , node ) {
29- if ( node . parentNode !== el || el . lastElementChild !== node ) {
30- el . appendChild ( node ) ;
28+ // Place marker before any inline error badge (e.g., .label.label-danger).
29+ function ensureBeforeError ( el , node ) {
30+ const err = el . querySelector ( 'strong.error' ) ;
31+ const errIsChild = err && err . parentNode === el ;
32+ if ( errIsChild ) {
33+ if ( node . parentNode !== el || node . nextElementSibling !== err ) {
34+ el . insertBefore ( node , err ) ;
35+ }
36+ } else {
37+ if ( node . parentNode !== el || el . lastElementChild !== node ) {
38+ el . appendChild ( node ) ;
39+ }
3140 }
3241 }
3342 function addMarker ( el ) {
4049 strong . setAttribute ( 'aria-hidden' , 'true' ) ;
4150 strong . textContent = `(${ Drupal . t ( 'required' ) } )` ;
4251 }
43- ensureAtEnd ( el , strong ) ;
52+ ensureBeforeError ( el , strong ) ;
4453 }
4554 function removeMarker ( el ) {
4655 el . classList . remove ( 'required' ) ;
You can’t perform that action at this time.
0 commit comments