jenkins-bot has submitted this change and it was merged.
Change subject: FieldLayout: Throw an error if no widget is provided
......................................................................
FieldLayout: Throw an error if no widget is provided
Bug: T76648
Change-Id: I6838d3538a3eb302027d2227843b73df4a791f38
---
M php/layouts/FieldLayout.php
M src/layouts/FieldLayout.js
2 files changed, 13 insertions(+), 0 deletions(-)
Approvals:
Bartosz Dziewoński: Looks good to me, approved
jenkins-bot: Verified
diff --git a/php/layouts/FieldLayout.php b/php/layouts/FieldLayout.php
index 778b4b1..bfa25af 100644
--- a/php/layouts/FieldLayout.php
+++ b/php/layouts/FieldLayout.php
@@ -61,6 +61,7 @@
* instances.
* @param array $config['notices'] Notices about the widget, as strings
or HtmlSnippet instances.
* @param string|HtmlSnippet $config['help'] Explanatory text shown as
a '?' icon.
+ * @throws Exception An exception is thrown if no widget is specified
*/
public function __construct( $fieldWidget, array $config = array() ) {
// Allow passing positional parameters inside the config array
@@ -69,6 +70,11 @@
$fieldWidget = $config['fieldWidget'];
}
+ // Make sure we have required constructor arguments
+ if ( $fieldWidget === null ) {
+ throw new Exception( 'Widget not found' );
+ }
+
$hasInputWidget = $fieldWidget::$supportsSimpleLabel;
// Config initialization
diff --git a/src/layouts/FieldLayout.js b/src/layouts/FieldLayout.js
index 9fcc237..ab94a32 100644
--- a/src/layouts/FieldLayout.js
+++ b/src/layouts/FieldLayout.js
@@ -34,6 +34,8 @@
* @cfg {string|OO.ui.HtmlSnippet} [help] Help text. When help text is
specified, a "help" icon will appear
* in the upper-right corner of the rendered field; clicking it will display
the text in a popup.
* For important messages, you are advised to use `notices`, as they are
always shown.
+ *
+ * @throws {Error} An error is thrown if no widget is specified
*/
OO.ui.FieldLayout = function OoUiFieldLayout( fieldWidget, config ) {
// Allow passing positional parameters inside the config object
@@ -42,6 +44,11 @@
fieldWidget = config.fieldWidget;
}
+ // Make sure we have required constructor arguments
+ if ( fieldWidget === undefined ) {
+ throw new Error( 'Widget not found' );
+ }
+
var hasInputWidget = fieldWidget.constructor.static.supportsSimpleLabel,
div, i;
--
To view, visit https://gerrit.wikimedia.org/r/231250
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I6838d3538a3eb302027d2227843b73df4a791f38
Gerrit-PatchSet: 3
Gerrit-Project: oojs/ui
Gerrit-Branch: master
Gerrit-Owner: Prtksxna <[email protected]>
Gerrit-Reviewer: Bartosz Dziewoński <[email protected]>
Gerrit-Reviewer: Prtksxna <[email protected]>
Gerrit-Reviewer: jenkins-bot <>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits