jenkins-bot has submitted this change and it was merged.
Change subject: Element: Add support for 'id' config option
......................................................................
Element: Add support for 'id' config option
Must be used sparingly, but has its use cases.
Change-Id: Iccbfb5ff18180961406828a39f3097eed7c963c1
---
M php/Element.php
M src/Element.js
2 files changed, 8 insertions(+), 0 deletions(-)
Approvals:
Trevor Parscal: Looks good to me, approved
jenkins-bot: Verified
diff --git a/php/Element.php b/php/Element.php
index be094f4..35ab53a 100644
--- a/php/Element.php
+++ b/php/Element.php
@@ -43,6 +43,7 @@
/**
* @param array $config Configuration options
* @param string[] $config['classes'] CSS class names to add
+ * @param string $config['id'] HTML id attribute
* @param array $config['content'] Content to append, strings or
Element objects. Strings will
* be HTML-escaped for output, use a HtmlSnippet instance to prevent
that.
*/
@@ -54,6 +55,9 @@
if ( isset( $config['classes'] ) && is_array(
$config['classes'] ) ) {
$this->addClasses( $config['classes'] );
}
+ if ( isset( $config['id'] ) ) {
+ $this->setAttributes( array( 'id' => $config['id'] ) );
+ }
if ( isset( $config['content'] ) ) {
$this->appendContent( $config['content'] );
}
diff --git a/src/Element.js b/src/Element.js
index e766b54..02f7127 100644
--- a/src/Element.js
+++ b/src/Element.js
@@ -8,6 +8,7 @@
* @param {Object} [config] Configuration options
* @cfg {Function} [$] jQuery for the frame the widget is in
* @cfg {string[]} [classes] CSS class names to add
+ * @cfg {string} [id] HTML id attribute
* @cfg {string} [text] Text to insert
* @cfg {jQuery} [$content] Content elements to append (after text)
* @cfg {Mixed} [data] Element data
@@ -28,6 +29,9 @@
if ( $.isArray( config.classes ) ) {
this.$element.addClass( config.classes.join( ' ' ) );
}
+ if ( config.id ) {
+ this.$element.attr( 'id', config.id );
+ }
if ( config.text ) {
this.$element.text( config.text );
}
--
To view, visit https://gerrit.wikimedia.org/r/183744
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: Iccbfb5ff18180961406828a39f3097eed7c963c1
Gerrit-PatchSet: 3
Gerrit-Project: oojs/ui
Gerrit-Branch: master
Gerrit-Owner: Bartosz DziewoĆski <[email protected]>
Gerrit-Reviewer: Trevor Parscal <[email protected]>
Gerrit-Reviewer: jenkins-bot <>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits