55 */
66
77const HIDDEN_TEXTAREA_STYLE = `
8- min-height:0 !important;
9- max-height:none !important;
10- height:0 !important;
11- visibility:hidden !important;
12- overflow:hidden !important;
13- position:absolute !important;
14- z-index:-1000 !important;
15- top:0 !important;
16- right:0 !important
8+ min-height:0 !important;
9+ max-height:none !important;
10+ height:0 !important;
11+ visibility:hidden !important;
12+ overflow:hidden !important;
13+ position:absolute !important;
14+ z-index:-1000 !important;
15+ top:0 !important;
16+ right:0 !important
1717`
1818
1919const SIZING_STYLE = [
@@ -38,37 +38,30 @@ const computedStyleCache = {}
3838let hiddenTextarea
3939
4040function calculateNodeStyling ( node , useCache = false ) {
41- const nodeRef = (
42- node . getAttribute ( 'id' ) ||
43- node . getAttribute ( 'data-reactid' ) ||
44- node . getAttribute ( 'name' )
45- )
41+ const nodeRef = ( node . getAttribute ( 'id' ) ||
42+ node . getAttribute ( 'data-reactid' ) ||
43+ node . getAttribute ( 'name' ) )
4644
4745 if ( useCache && computedStyleCache [ nodeRef ] ) {
4846 return computedStyleCache [ nodeRef ]
4947 }
5048
5149 const style = window . getComputedStyle ( node )
5250
53- const boxSizing = (
51+ const boxSizing =
5452 style . getPropertyValue ( 'box-sizing' ) ||
55- style . getPropertyValue ( '-moz-box-sizing' ) ||
56- style . getPropertyValue ( '-webkit-box-sizing' )
57- )
53+ style . getPropertyValue ( '-moz-box-sizing' ) ||
54+ style . getPropertyValue ( '-webkit-box-sizing' )
5855
59- const paddingSize = (
56+ const paddingSize =
6057 parseFloat ( style . getPropertyValue ( 'padding-bottom' ) ) +
61- parseFloat ( style . getPropertyValue ( 'padding-top' ) )
62- )
58+ parseFloat ( style . getPropertyValue ( 'padding-top' ) )
6359
64- const borderSize = (
60+ const borderSize =
6561 parseFloat ( style . getPropertyValue ( 'border-bottom-width' ) ) +
66- parseFloat ( style . getPropertyValue ( 'border-top-width' ) )
67- )
62+ parseFloat ( style . getPropertyValue ( 'border-top-width' ) )
6863
69- const sizingStyle = SIZING_STYLE
70- . map ( name => `${ name } :${ style . getPropertyValue ( name ) } ` )
71- . join ( ';' )
64+ const sizingStyle = SIZING_STYLE . map ( name => `${ name } :${ style . getPropertyValue ( name ) } ` ) . join ( ';' )
7265
7366 const nodeInfo = {
7467 sizingStyle,
@@ -105,33 +98,33 @@ export default function calculateNodeHeight (
10598
10699 // Copy all CSS properties that have an impact on the height of the content in
107100 // the textbox
108- const {
109- paddingSize , borderSize ,
110- boxSizing , sizingStyle ,
111- } = calculateNodeStyling ( uiTextNode , useCache )
101+ const { paddingSize , borderSize , boxSizing , sizingStyle } = calculateNodeStyling (
102+ uiTextNode ,
103+ useCache ,
104+ )
112105
113106 // Need to have the overflow attribute to hide the scrollbar otherwise
114107 // text-lines will not calculated properly as the shadow will technically be
115108 // narrower for content
116109 hiddenTextarea . setAttribute ( 'style' , `${ sizingStyle } ;${ HIDDEN_TEXTAREA_STYLE } ` )
117110 hiddenTextarea . value = uiTextNode . value || uiTextNode . placeholder || ''
118111
119- let minHeight = - Infinity
120- let maxHeight = Infinity
112+ let minHeight = Number . MIN_SAFE_INTEGER
113+ let maxHeight = Number . MAX_SAFE_INTEGER
121114 let height = hiddenTextarea . scrollHeight
122115 let overflowY
123116
124117 if ( boxSizing === 'border-box' ) {
125- // border-box: add border, since height = content + padding + border
118+ // border-box: add border, since height = content + padding + border
126119 height = height + borderSize
127120 } else if ( boxSizing === 'content-box' ) {
128- // remove padding, since height = content
121+ // remove padding, since height = content
129122 height = height - paddingSize
130123 }
131124
132125 if ( minRows !== null || maxRows !== null ) {
133- // measure height of a textarea with a single row
134- hiddenTextarea . value = ''
126+ // measure height of a textarea with a single row
127+ hiddenTextarea . value = ' '
135128 const singleRowHeight = hiddenTextarea . scrollHeight - paddingSize
136129 if ( minRows !== null ) {
137130 minHeight = singleRowHeight * minRows
@@ -150,6 +143,7 @@ export default function calculateNodeHeight (
150143 }
151144 }
152145 // Remove scroll bar flash when autosize without maxRows
146+ // donot remove in vue
153147 if ( ! maxRows ) {
154148 overflowY = 'hidden'
155149 }
0 commit comments