refactor: use data-mw- prefix for data attribute

This commit is contained in:
alistair3149 2024-05-23 22:05:28 -04:00
parent 7c760e9593
commit 177c67681e
No known key found for this signature in database
6 changed files with 8 additions and 8 deletions

View file

@ -165,7 +165,7 @@ class Tabber {
$tabBody = '<p>' . $tabBody . '</p>';
}
return '<article class="tabber__panel" data-title="' . $tabName .
return '<article class="tabber__panel" data-mw-tabber-title="' . $tabName .
'">' . $tabBody . '</article>';
}
}

View file

@ -149,7 +149,7 @@ class TabberTransclude {
);
}
$tab = '<article class="tabber__panel" data-title="' . htmlspecialchars( $tabName ) . '"';
$tab = '<article class="tabber__panel" data-mw-tabber-title="' . htmlspecialchars( $tabName ) . '"';
$tab .= implode( array_map( static function ( $prop, $value ) {
return sprintf( ' data-tabber-%s="%s"', $prop, htmlspecialchars( $value ) );
}, array_keys( $dataProps ), $dataProps ) );

View file

@ -15,7 +15,7 @@ function initApp( tabber ) {
};
tabs.forEach( ( tab ) => {
const label = tab.getAttribute( 'data-title' );
const label = tab.getAttribute( 'data-mw-tabber-title' );
tabberData.tabsData.push( {
name: mw.util.escapeIdForAttribute( label ),

View file

@ -6,7 +6,7 @@ const sizeProperties = Object.freeze( {
height: 'offsetHeight'
} );
// Temp element used by various extractTextFromHtml and getActualSize
// Temp element used by various extractTextFromHtml
const tempElement = document.createElement( 'div' );
/**
@ -50,7 +50,7 @@ function getActualSize( element, type ) {
const clone = element.cloneNode( true );
clone.style.position = 'absolute';
clone.style.visibility = 'hidden';
tempElement.appendChild( clone );
document.body.appendChild( clone );
value = clone[ sizeProperties[ type ] ];
clone.parentNode.removeChild( clone );
}
@ -125,7 +125,7 @@ function initTabber( tabber, count ) {
Array.prototype.forEach.call( tabPanels, function ( tabPanel ) {
const tab = document.createElement( 'a' );
let title = tabPanel.getAttribute( 'data-title' );
let title = tabPanel.getAttribute( 'data-mw-tabber-title' );
if ( config && config.parseTabName ) {
tab.innerHTML = title;

View file

@ -76,7 +76,7 @@ ve.ce.MWTabberNode.prototype.renderHeader = function ( tabber ) {
Array.prototype.forEach.call( tabPanels, function ( tabPanel, index ) {
const tab = document.createElement( 'a' );
tab.innerText = tabPanel.getAttribute( 'data-title' );
tab.innerText = tabPanel.getAttribute( 'data-mw-tabber-title' );
tab.classList.add( 'tabber__tab' );
// Make first tab active

View file

@ -73,7 +73,7 @@ ve.ce.MWTabberTranscludeNode.prototype.renderHeader = function ( tabber ) {
Array.prototype.forEach.call( tabPanels, function ( tabPanel, index ) {
const tab = document.createElement( 'a' );
tab.innerText = tabPanel.getAttribute( 'data-title' );
tab.innerText = tabPanel.getAttribute( 'data-mw-tabber-title' );
tab.classList.add( 'tabber__tab' );
// Make first tab active