mirror of
https://github.com/elastic/kibana.git
synced 2025-04-24 17:59:23 -04:00
Preparing for jQuery 3: size() -> length (#15648)
Per https://api.jquery.com/size/ - .size() is deprecated, and should be changed to .length Making this change alone already makes Kibana run with jQuery master.
This commit is contained in:
parent
74c3ddf78c
commit
1ade6d7c48
15 changed files with 55 additions and 55 deletions
|
@ -28,10 +28,10 @@ describe('Url Format', function () {
|
|||
|
||||
const $a = unwrap($(url.convert('http://elastic.co', 'html')));
|
||||
expect($a.is('a')).to.be(true);
|
||||
expect($a.size()).to.be(1);
|
||||
expect($a.length).to.be(1);
|
||||
expect($a.attr('href')).to.be('http://elastic.co');
|
||||
expect($a.attr('target')).to.be('_blank');
|
||||
expect($a.children().size()).to.be(0);
|
||||
expect($a.children().length).to.be(0);
|
||||
});
|
||||
|
||||
it('outputs a <a> link with target=_self if "open link in current tab" is checked', function () {
|
||||
|
@ -55,10 +55,10 @@ describe('Url Format', function () {
|
|||
const url = new Url({ urlTemplate: 'http://{{ value }}' });
|
||||
const $a = unwrap($(url.convert('url', 'html')));
|
||||
expect($a.is('a')).to.be(true);
|
||||
expect($a.size()).to.be(1);
|
||||
expect($a.length).to.be(1);
|
||||
expect($a.attr('href')).to.be('http://url');
|
||||
expect($a.attr('target')).to.be('_blank');
|
||||
expect($a.children().size()).to.be(0);
|
||||
expect($a.children().length).to.be(0);
|
||||
});
|
||||
|
||||
it('only outputs the url if the contentType === "text"', function () {
|
||||
|
@ -72,7 +72,7 @@ describe('Url Format', function () {
|
|||
const url = new Url({ labelTemplate: 'extension: {{ value }}', urlTemplate: 'http://www.{{value}}.com' });
|
||||
const $a = unwrap($(url.convert('php', 'html')));
|
||||
expect($a.is('a')).to.be(true);
|
||||
expect($a.size()).to.be(1);
|
||||
expect($a.length).to.be(1);
|
||||
expect($a.attr('href')).to.be('http://www.php.com');
|
||||
expect($a.html()).to.be('extension: php');
|
||||
});
|
||||
|
|
|
@ -92,7 +92,7 @@ describe('Integration', function () {
|
|||
|
||||
$rootScope.$on('renderComplete', () => {
|
||||
const $atg = $el.find('kbn-agg-table-group').first();
|
||||
expect($atg.size()).to.be(1);
|
||||
expect($atg.length).to.be(1);
|
||||
expect($atg.attr('group')).to.be('tableGroups');
|
||||
expect($atg.isolateScope().group).to.be($atg.scope().tableGroups);
|
||||
});
|
||||
|
@ -103,10 +103,10 @@ describe('Integration', function () {
|
|||
init(new OneRangeVis(), { hits: { total: 0, hits: [] } });
|
||||
|
||||
$rootScope.$on('renderComplete', () => {
|
||||
expect($el.find('kbn-agg-table-group').size()).to.be(0);
|
||||
expect($el.find('kbn-agg-table-group').length).to.be(0);
|
||||
|
||||
const $err = $el.find('.table-vis-error');
|
||||
expect($err.size()).to.be(1);
|
||||
expect($err.length).to.be(1);
|
||||
expect($err.text().trim()).to.be('No results found');
|
||||
});
|
||||
});
|
||||
|
@ -128,10 +128,10 @@ describe('Integration', function () {
|
|||
init(new ThreeTermVis(visParams), resp);
|
||||
|
||||
$rootScope.$on('renderComplete', () => {
|
||||
expect($el.find('kbn-agg-table-group').size()).to.be(0);
|
||||
expect($el.find('kbn-agg-table-group').length).to.be(0);
|
||||
|
||||
const $err = $el.find('.table-vis-error');
|
||||
expect($err.size()).to.be(1);
|
||||
expect($err.length).to.be(1);
|
||||
expect($err.text().trim()).to.be('No results found');
|
||||
});
|
||||
});
|
||||
|
|
|
@ -46,7 +46,7 @@ describe('tooltipFormatter', function () {
|
|||
const event = _.cloneDeep(baseEvent);
|
||||
const $el = $(tooltipFormatter(event));
|
||||
const $rows = $el.find('tr');
|
||||
expect($rows.size()).to.be(3);
|
||||
expect($rows.length).to.be(3);
|
||||
|
||||
const $row1 = $rows.eq(0).find('td');
|
||||
expect(cell($row1, 0)).to.be('inner');
|
||||
|
|
|
@ -45,7 +45,7 @@ describe('AggTableGroup Directive', function () {
|
|||
$scope.$digest();
|
||||
|
||||
// should create one sub-tbale
|
||||
expect($el.find('kbn-agg-table').size()).to.be(1);
|
||||
expect($el.find('kbn-agg-table').length).to.be(1);
|
||||
});
|
||||
|
||||
it('renders nothing if the table list is empty', function () {
|
||||
|
@ -59,7 +59,7 @@ describe('AggTableGroup Directive', function () {
|
|||
$scope.$digest();
|
||||
|
||||
const $subTables = $el.find('kbn-agg-table');
|
||||
expect($subTables.size()).to.be(0);
|
||||
expect($subTables.length).to.be(0);
|
||||
});
|
||||
|
||||
it('renders a complex response properly', function () {
|
||||
|
@ -82,10 +82,10 @@ describe('AggTableGroup Directive', function () {
|
|||
$scope.$digest();
|
||||
|
||||
const $subTables = $el.find('kbn-agg-table');
|
||||
expect($subTables.size()).to.be(3);
|
||||
expect($subTables.length).to.be(3);
|
||||
|
||||
const $subTableHeaders = $el.find('.agg-table-group-header');
|
||||
expect($subTableHeaders.size()).to.be(3);
|
||||
expect($subTableHeaders.length).to.be(3);
|
||||
|
||||
$subTableHeaders.each(function (i) {
|
||||
expect($(this).text()).to.be(group.tables[i].title);
|
||||
|
|
|
@ -44,8 +44,8 @@ describe('AggTable Directive', function () {
|
|||
const $el = $compile('<kbn-agg-table table="table"></kbn-agg-table>')($scope);
|
||||
$scope.$digest();
|
||||
|
||||
expect($el.find('tbody').size()).to.be(1);
|
||||
expect($el.find('td').size()).to.be(1);
|
||||
expect($el.find('tbody').length).to.be(1);
|
||||
expect($el.find('td').length).to.be(1);
|
||||
expect($el.find('td').text()).to.eql(1000);
|
||||
});
|
||||
|
||||
|
@ -54,7 +54,7 @@ describe('AggTable Directive', function () {
|
|||
const $el = $compile('<kbn-agg-table table="table"></kbn-agg-table>')($scope);
|
||||
$scope.$digest();
|
||||
|
||||
expect($el.find('tbody').size()).to.be(0);
|
||||
expect($el.find('tbody').length).to.be(0);
|
||||
});
|
||||
|
||||
it('renders a complex response properly', function () {
|
||||
|
@ -76,10 +76,10 @@ describe('AggTable Directive', function () {
|
|||
$compile($el)($scope);
|
||||
$scope.$digest();
|
||||
|
||||
expect($el.find('tbody').size()).to.be(1);
|
||||
expect($el.find('tbody').length).to.be(1);
|
||||
|
||||
const $rows = $el.find('tbody tr');
|
||||
expect($rows.size()).to.be.greaterThan(0);
|
||||
expect($rows.length).to.be.greaterThan(0);
|
||||
|
||||
function validBytes(str) {
|
||||
expect(str).to.match(/^\d+$/);
|
||||
|
@ -90,7 +90,7 @@ describe('AggTable Directive', function () {
|
|||
$rows.each(function () {
|
||||
// 6 cells in every row
|
||||
const $cells = $(this).find('td');
|
||||
expect($cells.size()).to.be(6);
|
||||
expect($cells.length).to.be(6);
|
||||
|
||||
const txts = $cells.map(function () {
|
||||
return $(this).text().trim();
|
||||
|
@ -144,13 +144,13 @@ describe('AggTable Directive', function () {
|
|||
$compile($el)($scope);
|
||||
$scope.$digest();
|
||||
|
||||
expect($el.find('tfoot').size()).to.be(1);
|
||||
expect($el.find('tfoot').length).to.be(1);
|
||||
|
||||
const $rows = $el.find('tfoot tr');
|
||||
expect($rows.size()).to.be(1);
|
||||
expect($rows.length).to.be(1);
|
||||
|
||||
const $cells = $($rows[0]).find('th');
|
||||
expect($cells.size()).to.be(6);
|
||||
expect($cells.length).to.be(6);
|
||||
|
||||
for (let i = 0; i < 6; i++) {
|
||||
expect($($cells[i]).text()).to.be(expected[i]);
|
||||
|
|
|
@ -10,13 +10,13 @@ uiModules.get('kibana')
|
|||
link: {
|
||||
pre: function ($scope, $el, attrs) {
|
||||
if (_.isUndefined(attrs.bottomControls)) attrs.bottomControls = true;
|
||||
if ($el.find('paginate-controls.paginate-bottom').size() === 0 && attrs.bottomControls) {
|
||||
if ($el.find('paginate-controls.paginate-bottom').length === 0 && attrs.bottomControls) {
|
||||
$el.append($compile('<paginate-controls class="paginate-bottom">')($scope));
|
||||
}
|
||||
},
|
||||
post: function ($scope, $el, attrs) {
|
||||
if (_.isUndefined(attrs.topControls)) attrs.topControls = false;
|
||||
if ($el.find('paginate-controls.paginate-top').size() === 0 && attrs.topControls) {
|
||||
if ($el.find('paginate-controls.paginate-top').length === 0 && attrs.topControls) {
|
||||
$el.prepend($compile('<paginate-controls class="paginate-top">')($scope));
|
||||
}
|
||||
|
||||
|
|
|
@ -159,7 +159,7 @@ module.directive('kbnTableRow', function ($compile, $httpParamSerializer, kbnUrl
|
|||
const $target = reuse ? $(reuse).detach() : $(html);
|
||||
$target.data('discover:html', html);
|
||||
const $before = $cells.eq(i - 1);
|
||||
if ($before.size()) {
|
||||
if ($before.length) {
|
||||
$before.after($target);
|
||||
} else {
|
||||
$el.append($target);
|
||||
|
|
|
@ -22,8 +22,8 @@ describe('jQuery.findTestSubject', function () {
|
|||
const $otherMatch = $make('subject').appendTo($container);
|
||||
|
||||
const $found = $container.findTestSubject('subject');
|
||||
expect($found.filter($match).size()).to.be(1);
|
||||
expect($found.filter($otherMatch).size()).to.be(1);
|
||||
expect($found.filter($match).length).to.be(1);
|
||||
expect($found.filter($otherMatch).length).to.be(1);
|
||||
});
|
||||
|
||||
it('finds all of the elements with either subject', function () {
|
||||
|
@ -33,9 +33,9 @@ describe('jQuery.findTestSubject', function () {
|
|||
const $noMatch = $make('notSubject').appendTo($container);
|
||||
|
||||
const $found = $container.findTestSubject('subject', 'alsoSubject');
|
||||
expect($found.filter($match1).size()).to.be(1);
|
||||
expect($found.filter($match2).size()).to.be(1);
|
||||
expect($found.filter($noMatch).size()).to.be(0);
|
||||
expect($found.filter($match1).length).to.be(1);
|
||||
expect($found.filter($match2).length).to.be(1);
|
||||
expect($found.filter($noMatch).length).to.be(0);
|
||||
});
|
||||
|
||||
it('finds all of the elements with a decendant selector', function () {
|
||||
|
|
|
@ -345,7 +345,7 @@ Notifier.prototype._showFatal = function (err) {
|
|||
|
||||
let $container = $('#fatal-splash-screen');
|
||||
|
||||
if (!$container.size()) {
|
||||
if (!$container.length) {
|
||||
$(document.body)
|
||||
// in case the app has not completed boot
|
||||
.removeAttr('ng-cloak')
|
||||
|
|
|
@ -53,7 +53,7 @@ uiModules
|
|||
function go(dir) {
|
||||
return function () {
|
||||
const $to = $get(dir);
|
||||
if ($to.size()) $to.focus();
|
||||
if ($to.length) $to.focus();
|
||||
else return false;
|
||||
};
|
||||
}
|
||||
|
|
|
@ -80,7 +80,7 @@ describe('paginated table', function () {
|
|||
const rows = [];
|
||||
|
||||
renderTable(cols, rows);
|
||||
expect($el.children().size()).to.be(0);
|
||||
expect($el.children().length).to.be(0);
|
||||
});
|
||||
|
||||
it('should render columns and rows', function () {
|
||||
|
@ -89,10 +89,10 @@ describe('paginated table', function () {
|
|||
const rows = data.rows;
|
||||
|
||||
renderTable(cols, rows);
|
||||
expect($el.children().size()).to.be(1);
|
||||
expect($el.children().length).to.be(1);
|
||||
const tableRows = $el.find('tbody tr');
|
||||
// should pad rows
|
||||
expect(tableRows.size()).to.be(defaultPerPage);
|
||||
expect(tableRows.length).to.be(defaultPerPage);
|
||||
// should contain the row data
|
||||
expect(tableRows.eq(0).find('td').eq(0).text()).to.be(rows[0][0]);
|
||||
expect(tableRows.eq(0).find('td').eq(1).text()).to.be(rows[0][1]);
|
||||
|
@ -109,9 +109,9 @@ describe('paginated table', function () {
|
|||
|
||||
renderTable(data.columns, data.rows, perPageCount);
|
||||
const tableRows = $el.find('tbody tr');
|
||||
expect(tableRows.size()).to.be(perPageCount);
|
||||
expect(tableRows.length).to.be(perPageCount);
|
||||
// add 2 for the first and last page links
|
||||
expect($el.find('paginate-controls button').size()).to.be(pageCount + 2);
|
||||
expect($el.find('paginate-controls button').length).to.be(pageCount + 2);
|
||||
});
|
||||
|
||||
it('should not show blank rows on last page when so specified', function () {
|
||||
|
@ -121,7 +121,7 @@ describe('paginated table', function () {
|
|||
|
||||
renderTable(data.columns, data.rows, perPageCount, null, false);
|
||||
const tableRows = $el.find('tbody tr');
|
||||
expect(tableRows.size()).to.be(rowCount);
|
||||
expect(tableRows.length).to.be(rowCount);
|
||||
});
|
||||
|
||||
it('should not show link to top when not set', function () {
|
||||
|
@ -129,7 +129,7 @@ describe('paginated table', function () {
|
|||
renderTable(data.columns, data.rows, 10, null, false);
|
||||
|
||||
const linkToTop = $el.find('[data-test-subj="paginateControlsLinkToTop"]');
|
||||
expect(linkToTop.size()).to.be(0);
|
||||
expect(linkToTop.length).to.be(0);
|
||||
});
|
||||
|
||||
it('should show link to top when set', function () {
|
||||
|
@ -137,7 +137,7 @@ describe('paginated table', function () {
|
|||
renderTable(data.columns, data.rows, 10, null, false, true);
|
||||
|
||||
const linkToTop = $el.find('[data-test-subj="paginateControlsLinkToTop"]');
|
||||
expect(linkToTop.size()).to.be(1);
|
||||
expect(linkToTop.length).to.be(1);
|
||||
});
|
||||
|
||||
});
|
||||
|
@ -367,27 +367,27 @@ describe('paginated table', function () {
|
|||
|
||||
it('should append object markup', function () {
|
||||
const tableRows = $el.find('tbody tr');
|
||||
expect(tableRows.eq(0).find('h1').size()).to.be(0);
|
||||
expect(tableRows.eq(1).find('h1').size()).to.be(1);
|
||||
expect(tableRows.eq(2).find('h1').size()).to.be(0);
|
||||
expect(tableRows.eq(0).find('h1').length).to.be(0);
|
||||
expect(tableRows.eq(1).find('h1').length).to.be(1);
|
||||
expect(tableRows.eq(2).find('h1').length).to.be(0);
|
||||
});
|
||||
|
||||
it('should sort using object value', function () {
|
||||
paginatedTable.sortColumn(0);
|
||||
$scope.$digest();
|
||||
let tableRows = $el.find('tbody tr');
|
||||
expect(tableRows.eq(0).find('h1').size()).to.be(0);
|
||||
expect(tableRows.eq(1).find('h1').size()).to.be(0);
|
||||
expect(tableRows.eq(0).find('h1').length).to.be(0);
|
||||
expect(tableRows.eq(1).find('h1').length).to.be(0);
|
||||
// html row should be the last row
|
||||
expect(tableRows.eq(2).find('h1').size()).to.be(1);
|
||||
expect(tableRows.eq(2).find('h1').length).to.be(1);
|
||||
|
||||
paginatedTable.sortColumn(0);
|
||||
$scope.$digest();
|
||||
tableRows = $el.find('tbody tr');
|
||||
// html row should be the first row
|
||||
expect(tableRows.eq(0).find('h1').size()).to.be(1);
|
||||
expect(tableRows.eq(1).find('h1').size()).to.be(0);
|
||||
expect(tableRows.eq(2).find('h1').size()).to.be(0);
|
||||
expect(tableRows.eq(0).find('h1').length).to.be(1);
|
||||
expect(tableRows.eq(1).find('h1').length).to.be(0);
|
||||
expect(tableRows.eq(2).find('h1').length).to.be(0);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
|
@ -12,7 +12,7 @@ export function ResizeCheckerProvider(Private) {
|
|||
// so we wrap in jQuery then extract the element
|
||||
const $el = $(el);
|
||||
|
||||
if ($el.size() !== 1) {
|
||||
if ($el.length !== 1) {
|
||||
throw new TypeError('ResizeChecker must be constructed with a single DOM element.');
|
||||
}
|
||||
|
||||
|
|
|
@ -19,7 +19,7 @@ export function positionTooltip(opts, html) {
|
|||
const prev = $chart.data('previousPlacement') || {};
|
||||
const event = opts.event;
|
||||
|
||||
if (!$chart.size() || !$el.size()) return;
|
||||
if (!$chart.length || !$el.length) return;
|
||||
|
||||
const size = getTtSize(html || $el.html(), $sizer);
|
||||
const pos = getBasePosition(size, event);
|
||||
|
|
|
@ -101,7 +101,7 @@ Tooltip.prototype.hide = function () {
|
|||
*/
|
||||
Tooltip.prototype.$getChart = function () {
|
||||
const chart = $(this.container && this.container.node());
|
||||
return chart.size() ? chart : false;
|
||||
return chart.length ? chart : false;
|
||||
};
|
||||
|
||||
/**
|
||||
|
|
|
@ -165,7 +165,7 @@ uiModules
|
|||
function jQueryGetter(selector) {
|
||||
return function () {
|
||||
const $sel = $el.find(selector);
|
||||
if ($sel.size()) return $sel;
|
||||
if ($sel.length) return $sel;
|
||||
};
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue