@@ -1355,12 +1355,17 @@ class OutputManager {
1355
1355
getSelectorFromElement ( element , fallback ) {
1356
1356
var el , type , selector ;
1357
1357
1358
- el = element . el ;
1358
+ el = element . getTargetElement ( ) ;
1359
1359
type = this . getSelectorType ( el ) ;
1360
1360
selector = this . getSelectorForType ( type , el ) ;
1361
1361
1362
1362
if ( ! selector && ( fallback || type !== Settings . OUTPUT_SELECTOR_NONE ) ) {
1363
- selector = el . tagName . toLowerCase ( ) ;
1363
+ let tag = el . tagName . toLowerCase ( ) ;
1364
+ if ( tag === 'input' ) {
1365
+ selector = `input[type="${ el . type } "]` ;
1366
+ } else {
1367
+ selector = tag ;
1368
+ }
1364
1369
}
1365
1370
return selector ;
1366
1371
}
@@ -2308,7 +2313,7 @@ class PositionableElementManager {
2308
2313
els = [ ] ;
2309
2314
}
2310
2315
2311
- for ( let i = 0 , el ; el = els [ i ] ; i ++ ) {
2316
+ for ( let el of els ) {
2312
2317
if ( includeSelector || this . canAutoAddElement ( el ) ) {
2313
2318
this . elements . push ( new PositionableElement ( this , el ) ) ;
2314
2319
}
@@ -2612,7 +2617,7 @@ class DragTarget extends BrowserEventTarget {
2612
2617
2613
2618
setupInteractiveElements ( ) {
2614
2619
var els = this . el . querySelectorAll ( DragTarget . INTERACTIVE_ELEMENTS_SELECTOR ) ;
2615
- for ( let i = 0 , el ; el = els [ i ] ; i ++ ) {
2620
+ for ( let el of els ) {
2616
2621
var element = new BrowserEventTarget ( el ) ;
2617
2622
element . stopPropagation ( 'mousedown' ) ;
2618
2623
element . stopPropagation ( 'click' ) ;
@@ -4036,7 +4041,7 @@ class Settings {
4036
4041
parseGroupingMap ( str ) {
4037
4042
var lines = str . split ( '\n' ) , data = { } ;
4038
4043
lines = lines . filter ( l => l ) ;
4039
- for ( let i = 0 , line ; line = lines [ i ] ; i ++ ) {
4044
+ for ( let line of lines ) {
4040
4045
var match , key , val ;
4041
4046
match = line . match ( / \s * ( [ ^ : ] + ) : \s * ( [ ^ ; ] + ) / ) ;
4042
4047
if ( ! match ) {
@@ -4192,7 +4197,7 @@ class SettingsForm extends BrowserEventTarget {
4192
4197
if ( val ) {
4193
4198
switch ( control . type ) {
4194
4199
case SettingsForm . SELECT_ONE :
4195
- for ( var i = 0 , option ; option = control . options [ i ] ; i ++ ) {
4200
+ for ( let option of control . options ) {
4196
4201
if ( option . value === val ) {
4197
4202
option . selected = true ;
4198
4203
}
@@ -4303,7 +4308,7 @@ class SettingsForm extends BrowserEventTarget {
4303
4308
4304
4309
getFirstControl ( ) {
4305
4310
var els = this . el . elements ;
4306
- for ( var i = 0 , control ; control = els [ i ] ; i ++ ) {
4311
+ for ( let control of els ) {
4307
4312
if ( control . id ) {
4308
4313
return control ;
4309
4314
}
@@ -4312,7 +4317,7 @@ class SettingsForm extends BrowserEventTarget {
4312
4317
4313
4318
forEachControl ( fn ) {
4314
4319
var els = this . el . elements ;
4315
- for ( var i = 0 , control ; control = els [ i ] ; i ++ ) {
4320
+ for ( let control of els ) {
4316
4321
if ( control . id ) {
4317
4322
fn ( control ) ;
4318
4323
}
@@ -4355,7 +4360,7 @@ class LinkedSelect extends BrowserEventTarget {
4355
4360
setup ( ) {
4356
4361
this . linked = { } ;
4357
4362
var els = this . el . parentNode . querySelectorAll ( '[data-linked-option]' ) ;
4358
- for ( var i = 0 , el ; el = els [ i ] ; i ++ ) {
4363
+ for ( let el of els ) {
4359
4364
this . linked [ el . dataset . linkedOption ] = new Element ( el ) ;
4360
4365
}
4361
4366
this . bindEvent ( 'change' , this . onChange ) ;
@@ -4532,6 +4537,23 @@ class CopyAnimation extends Animation {
4532
4537
4533
4538
/*-------------------------] PositionableElement [--------------------------*/
4534
4539
4540
+ const EMPTY_ELEMENT_TAGS = [
4541
+ 'AREA' ,
4542
+ 'BASE' ,
4543
+ 'BR' ,
4544
+ 'COL' ,
4545
+ 'EMBED' ,
4546
+ 'HR' ,
4547
+ 'IMG' ,
4548
+ 'INPUT' ,
4549
+ 'LINK' ,
4550
+ 'META' ,
4551
+ 'PARAM' ,
4552
+ 'SOURCE' ,
4553
+ 'TRACK' ,
4554
+ 'WBR' ,
4555
+ ] ;
4556
+
4535
4557
class PositionableElement extends BrowserEventTarget {
4536
4558
4537
4559
static get UI_FOCUSED_CLASS ( ) { return 'ui--focused' ; }
@@ -4546,6 +4568,8 @@ class PositionableElement extends BrowserEventTarget {
4546
4568
this . states = [ ] ;
4547
4569
4548
4570
this . setup ( ) ;
4571
+
4572
+ return this . linkedInterface || this ;
4549
4573
}
4550
4574
4551
4575
// --- Manipulation
@@ -4631,6 +4655,10 @@ class PositionableElement extends BrowserEventTarget {
4631
4655
4632
4656
// --- Other
4633
4657
4658
+ getTargetElement ( ) {
4659
+ return this . linkedEl || this . el ;
4660
+ }
4661
+
4634
4662
getRotation ( ) {
4635
4663
return this . cssTransform . getRotation ( ) ;
4636
4664
}
@@ -4733,7 +4761,11 @@ class PositionableElement extends BrowserEventTarget {
4733
4761
setup ( ) {
4734
4762
this . setupEvents ( ) ;
4735
4763
this . setupInitialState ( ) ;
4736
- this . injectInterface ( ) ;
4764
+ if ( this . isEmptyElement ( ) ) {
4765
+ this . createLinkedInterface ( ) ;
4766
+ } else {
4767
+ this . injectInterface ( ) ;
4768
+ }
4737
4769
}
4738
4770
4739
4771
setupEvents ( ) {
@@ -4750,6 +4782,28 @@ class PositionableElement extends BrowserEventTarget {
4750
4782
this . cssBackgroundImage = CSSBackgroundImage . fromMatcher ( matcher ) ;
4751
4783
}
4752
4784
4785
+ isEmptyElement ( ) {
4786
+ return EMPTY_ELEMENT_TAGS . includes ( this . el . tagName ) ;
4787
+ }
4788
+
4789
+ createLinkedInterface ( ) {
4790
+ const { el } = this ;
4791
+ var style = window . getComputedStyle ( el ) ;
4792
+ var div = document . createElement ( 'div' ) ;
4793
+ el . parentNode . append ( div ) ;
4794
+ div . style . position = style . position ;
4795
+ div . style . top = style . top ;
4796
+ div . style . left = style . left ;
4797
+ div . style . width = style . width ;
4798
+ div . style . height = style . height ;
4799
+ div . style . margin = style . margin ;
4800
+ div . style . padding = style . padding ;
4801
+ div . style . border = style . border ;
4802
+ div . style . borderColor = 'transparent' ;
4803
+ this . linkedInterface = new PositionableElement ( this . listener , div ) ;
4804
+ this . linkedInterface . linkedEl = this . el ;
4805
+ }
4806
+
4753
4807
injectInterface ( ) {
4754
4808
// As the UI is injected before any other elements, placing it at the
4755
4809
// top level means that nested positionable elements will override it
@@ -5078,6 +5132,9 @@ class PositionableElement extends BrowserEventTarget {
5078
5132
5079
5133
renderBox ( ) {
5080
5134
this . cssBox . render ( this . el . style ) ;
5135
+ if ( this . linkedEl ) {
5136
+ this . cssBox . render ( this . linkedEl . style ) ;
5137
+ }
5081
5138
if ( this . isPeeking ) {
5082
5139
var p = this . getPeekDimensions ( ) ;
5083
5140
this . el . style . width = p . x + 'px' ;
@@ -5087,6 +5144,9 @@ class PositionableElement extends BrowserEventTarget {
5087
5144
5088
5145
renderTransform ( ) {
5089
5146
this . cssTransform . render ( this . el . style ) ;
5147
+ if ( this . linkedEl ) {
5148
+ this . cssTransform . render ( this . linkedEl . style ) ;
5149
+ }
5090
5150
}
5091
5151
5092
5152
renderBackgroundPosition ( ) {
@@ -7346,5 +7406,4 @@ function roundWithPrecision(n, precision) {
7346
7406
return Math . round ( n * mult ) / mult ;
7347
7407
}
7348
7408
7349
-
7350
7409
window . AppController = AppController ;
0 commit comments