Closed domchristie closed 9 years ago
When I load the home page with this applied, I'm not seeing the demo textarea expand for some reason
(no errors in the console, happens on FF and Chrome)
Sorry about that. One of the few things not covered by tests!
Fixed by https://github.com/domchristie/ExpandingTextareas/commit/ec35959994d85c8ac59ffb034aa768a9880ecbdd
Sorry about that. One of the few things not covered by tests!
Ah, autoinitialization. We should probably have a test cover this
Ah, autoinitialization. We should probably have a test cover this
I have attempted this, but it’s not straightforward given that the init code is called inside a jQuery document ready handler (any ideas?).
We could just test the presence of the correct $.expanding
options, which would have failed in this case.
We could just test the presence of the correct $.expanding options, which would have failed in this case.
Yeah, that would be a good place to start
I have attempted this, but it’s not straightforward given that the init code is called inside a jQuery document ready handler (any ideas?).
The test harness will be running before document ready has fired, so maybe we could do an async test that waits to resolve until after the DOM is ready. Registering a $(function() {}) inside the test should cause that one to fire after the one registered in expanding.js. You can call asyncTest to do this with qunit. Here is an example: https://github.com/bgrins/spectrum/compare/bgrins:e295dbe...bgrins:eb4cd0e#diff-38dcab2adf8a7e3431829d8daca050fcR658.
I think the issue is that the #qunit-fixture
element is reset after each test, meaning that an auto-initialized expanding textarea will lose its data
after the first test. Checking for an active expanding textarea will fail unless the test is the first one that is run.
Checking for an active expanding textarea will fail unless the test is the first one that is run.
If this is the case, I'd have no problem with just putting that test first with a comment about why it is there. Or even adding a new test html file just for this case.
Or even adding a new test html file just for this case.
This is preferable since QUnit re-runs failing tests first, which can lead to odd results i.e. tests fail initially, then pass on refresh
This reverts storing initialised
Expanding
instances indata
(rather than in a registry) as it leads to more understandable code. (Takes some inspiration from twitter bootstrap plugins.)It also removes the
$.expanding.opts.update
option. This is used to provide a default callback on update, but is not documented, and is a little confusing. Note:$('textarea').expanding({ update: function () {} });
is still supported..jshintrc
is updated, and .js files have been updated to reflect these changes.