Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-ce
Commits
32d88db6
Commit
32d88db6
authored
Sep 16, 2020
by
André Luís
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix autosize using waitForCSSLoaded
parent
daecc94d
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
19 additions
and
10 deletions
+19
-10
app/assets/javascripts/behaviors/autosize.js
app/assets/javascripts/behaviors/autosize.js
+8
-3
spec/frontend/behaviors/autosize_spec.js
spec/frontend/behaviors/autosize_spec.js
+11
-7
No files found.
app/assets/javascripts/behaviors/autosize.js
View file @
32d88db6
import
Autosize
from
'
autosize
'
;
import
{
waitForCSSLoaded
}
from
'
../helpers/startup_css_helper
'
;
document
.
addEventListener
(
'
DOMContentLoaded
'
,
()
=>
{
const
autosizeEls
=
document
.
querySelectorAll
(
'
.js-autosize
'
);
waitForCSSLoaded
(()
=>
{
const
autosizeEls
=
document
.
querySelectorAll
(
'
.js-autosize
'
);
Autosize
(
autosizeEls
);
Autosize
.
update
(
autosizeEls
);
Autosize
(
autosizeEls
);
Autosize
.
update
(
autosizeEls
);
autosizeEls
.
forEach
(
el
=>
el
.
classList
.
add
(
'
js-autosize-initialized
'
));
});
});
spec/frontend/behaviors/autosize_spec.js
View file @
32d88db6
import
$
from
'
jquery
'
;
import
'
~/behaviors/autosize
'
;
function
load
()
{
$
(
document
).
trigger
(
'
load
'
);
document
.
dispatchEvent
(
new
Event
(
'
DOMContentLoaded
'
)
);
}
jest
.
mock
(
'
~/helpers/startup_css_helper
'
,
()
=>
{
return
{
waitForCSSLoaded
:
jest
.
fn
().
mockImplementation
(
cb
=>
cb
.
apply
()),
};
});
describe
(
'
Autosize behavior
'
,
()
=>
{
beforeEach
(()
=>
{
setFixtures
(
'
<textarea class="js-autosize"
style="resize: vertical"
></textarea>
'
);
setFixtures
(
'
<textarea class="js-autosize"></textarea>
'
);
});
it
(
'
does not overwrite the resize property
'
,
()
=>
{
it
(
'
is applied to the textarea
'
,
()
=>
{
load
();
expect
(
$
(
'
textarea
'
)).
toHaveCss
({
resize
:
'
vertical
'
,
});
const
textarea
=
document
.
querySelector
(
'
textarea
'
);
expect
(
textarea
.
classList
).
toContain
(
'
js-autosize-initialized
'
);
});
});
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment