Skip to content

Commit

Permalink
Support return null for wire function
Browse files Browse the repository at this point in the history
  • Loading branch information
jimmyshiau committed May 5, 2022
1 parent 9484d44 commit 28cb180
Show file tree
Hide file tree
Showing 12 changed files with 16 additions and 15 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

**2.0.1**
* Fixed tooltip and popover position
* Support return null for wire function

**2.0.0**
* Migrate to null safety
Expand Down
2 changes: 1 addition & 1 deletion lib/src/affix.dart
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ class Affix extends Base {
/**
*
*/
static Affix wire(Element element, [Affix create()?]) =>
static Affix? wire(Element element, [Affix? create()?]) =>
p.wire(element, _name, create ?? (() => Affix(element)));

/**
Expand Down
2 changes: 1 addition & 1 deletion lib/src/alert.dart
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ class Alert extends Base {
* + [create] - If provided, it will be used for Alert creation. Otherwise
* the default constructor with no optional parameter value is used.
*/
static Alert wire(Element element, [Alert create()?]) =>
static Alert? wire(Element element, [Alert? create()?]) =>
p.wire(element, _name, create ?? (() => Alert(element)));

/** Detach the Alert component from DOM.
Expand Down
4 changes: 2 additions & 2 deletions lib/src/button.dart
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ class Button extends Base {
* + [create] - If provided, it will be used for Button creation. Otherwise
* the default constructor with no optional parameter value is used.
*/
static Button wire(Element element, [Button create()?]) =>
static Button? wire(Element element, [Button? create()?]) =>
p.wire(element, _name, create ?? (() => Button(element)));

/** Set the button state, which will change the button text according to [texts]
Expand Down Expand Up @@ -87,7 +87,7 @@ class Button extends Base {
if (e.target is Element) {
final $btn = $(e.target).closest('.btn');
if ($btn.isNotEmpty)
Button.wire($btn.first).toggle();
Button.wire($btn.first)!.toggle();
}

}, selector: '[data-toggle^=button]');
Expand Down
4 changes: 2 additions & 2 deletions lib/src/collapse.dart
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ class Collapse extends Base {
* + [create] - If provided, it will be used for Collapse creation. Otherwise
* the default constructor with no optional parameter value is used.
*/
static Collapse wire(Element element, [Collapse create()?]) =>
static Collapse? wire(Element element, [Collapse? create()?]) =>
p.wire(element, _name, create ?? (() => Collapse(element)));


Expand Down Expand Up @@ -65,7 +65,7 @@ class Collapse extends Base {
if (active?.transitioning ?? false)
return;

Collapse.wire(elem).hide();
Collapse.wire(elem)!.hide();
$(elem).data.set(_name, null);
}

Expand Down
2 changes: 1 addition & 1 deletion lib/src/dropdown.dart
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ class Dropdown extends Base {
* + [create] - If provided, it will be used for Dropdown creation. Otherwise
* the default constructor with no optional parameter value is used.
*/
static Dropdown wire(Element element, [Dropdown create()?]) =>
static Dropdown? wire(Element element, [Dropdown? create()?]) =>
p.wire(element, _name, create ?? (() => Dropdown(element)));

/** Toggle the open/close state of the Dropdown.
Expand Down
4 changes: 2 additions & 2 deletions lib/src/modal.dart
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ class Modal extends Base {
* + [create] - If provided, it will be used for Modal creation. Otherwise
* the default constructor with no optional parameter value is used.
*/
static Modal wire(Element element, [Modal create()?]) =>
static Modal? wire(Element element, [Modal? create()?]) =>
p.wire(element, _name, create ?? (() => Modal(element)));

/** Toggle the visibility state of the Modal.
Expand Down Expand Up @@ -224,7 +224,7 @@ class Modal extends Base {
return;

// , option = $target.data('modal') ? 'toggle' : $.extend({ remote:!/#/.test(href) && href }, $target.data(), $this.data())
Modal.wire($target.first, () => Modal($target.first)).toggle(); // TODO: other options
Modal.wire($target.first, () => Modal($target.first))!.toggle(); // TODO: other options

$target.one('hide', (QueryEvent e) => $(elem).trigger('focus'));

Expand Down
2 changes: 1 addition & 1 deletion lib/src/popover.dart
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ class Popover extends Tooltip {
* + [create] - If provided, it will be used for Popover creation. Otherwise
* the default constructor with no optional parameter value is used.
*/
static Popover wire(Element element, [Popover create()?]) =>
static Popover? wire(Element element, [Popover? create()?]) =>
p.wire(element, _name, create ?? (() => Popover(element)));

@override
Expand Down
2 changes: 1 addition & 1 deletion lib/src/scrollspy.dart
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ class Scrollspy extends Base {
* Scrollspy object, a new one will be created.
*
*/
static Scrollspy wire(Element element, [Scrollspy create()?]) =>
static Scrollspy? wire(Element element, [Scrollspy? create()?]) =>
p.wire(element, _name, create ?? (() => Scrollspy(element)));

final ElementQuery _$body;
Expand Down
4 changes: 2 additions & 2 deletions lib/src/tab.dart
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ class Tab extends Base {
* + [create] - If provided, it will be used for Tab creation. Otherwise
* the default constructor with no optional parameter value is used.
*/
static Tab wire(Element element, [Tab create()?]) =>
static Tab? wire(Element element, [Tab? create()?]) =>
p.wire(element, _name, create ?? (() => Tab(element)));

/** Show the tab.
Expand Down Expand Up @@ -94,7 +94,7 @@ class Tab extends Base {

$document().on('click.tab.data-api', (QueryEvent e) {
e.preventDefault();
wire(e.target as Element).show();
wire(e.target as Element)!.show();

}, selector: '[data-toggle="tab"], [data-toggle="pill"]');
}
Expand Down
2 changes: 1 addition & 1 deletion lib/src/tooltip.dart
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ class Tooltip extends Base {
* + [create] - If provided, it will be used for Tooltip creation. Otherwise
* the default constructor with no optional parameter value is used.
*/
static Tooltip wire(Element element, [Tooltip create()?]) =>
static Tooltip? wire(Element element, [Tooltip? create()?]) =>
p.wire(element, _name, create ?? (() => Tooltip(element)));

String get _type => _name;
Expand Down
2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: bootjack
version: 2.0.0+1
version: 2.0.1
description: Bootjack is a porting of Twitter Bootstrap 3.0.x in Dart.
homepage: https://github.com/rikulo/bootjack
documentation: http://blog.rikulo.org/posts/2013/May/General/bootjack-and-dquery/
Expand Down

0 comments on commit 28cb180

Please sign in to comment.