mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/VisualEditor
synced 2024-11-24 22:35:41 +00:00
ve.Element: Account for getComputerStyle returning null
Follows-up 143b086c74
.
When the page settings dialog is opened, ve.Element.getBorders
gets called twice and in both cases, style is null in Firefox:
* HTMLLIElement
classList: "ve-ui-widget ve-ui-optionWidget ve-ui-outlineItemWidget
ve-ui-outlineItemWidget-level-0 ve-ui-optionWidget-selected"
childNodes: [object HTMLSpanElement, object HTMLDivElement]
* HTMLDivElement
classList: "ve-ui-layout ve-ui-panelLayout ve-ui-panelLayout-scrollable
ve-ltr ve-ui-pagedDialog-outlinePanel"
childNodes: [object HTMLUListElement]
Bug: 54322
Change-Id: I86264007c2d5b4930640a352b8896dff2d0d9ce5
This commit is contained in:
parent
7481ea024d
commit
5276bf13c1
|
@ -175,15 +175,14 @@ ve.Element.getRelativePosition = function ( $from, $to ) {
|
|||
ve.Element.getBorders = function ( el ) {
|
||||
var doc = el.ownerDocument,
|
||||
win = doc.parentWindow || doc.defaultView,
|
||||
loc = win && win.getComputedStyle,
|
||||
style = loc ?
|
||||
style = win && win.getComputedStyle ?
|
||||
win.getComputedStyle( el, null ) :
|
||||
el.currentStyle,
|
||||
$el = $( el ),
|
||||
top = parseFloat( loc ? style.borderTopWidth : $el.css( 'borderTopWidth' ) ) || 0,
|
||||
left = parseFloat( loc ? style.borderLeftWidth : $el.css( 'borderLeftWidth' ) ) || 0,
|
||||
bottom = parseFloat( loc ? style.borderBottomWidth : $el.css( 'borderBottomWidth' ) ) || 0,
|
||||
right = parseFloat( loc ? style.borderRightWidth : $el.css( 'borderRightWidth' ) ) || 0;
|
||||
top = parseFloat( style ? style.borderTopWidth : $el.css( 'borderTopWidth' ) ) || 0,
|
||||
left = parseFloat( style ? style.borderLeftWidth : $el.css( 'borderLeftWidth' ) ) || 0,
|
||||
bottom = parseFloat( style ? style.borderBottomWidth : $el.css( 'borderBottomWidth' ) ) || 0,
|
||||
right = parseFloat( style ? style.borderRightWidth : $el.css( 'borderRightWidth' ) ) || 0;
|
||||
|
||||
return {
|
||||
'top': Math.round( top ),
|
||||
|
|
Loading…
Reference in a new issue