jasmine-jquery
jasmine-jquery copied to clipboard
Can't set lang attribute on element
When I set the "lang" attribute on an element, it does not get set.
Here is a test that won't pass:
// source code
$(D.CONTAINER).attr('lang', lang);
// test
expect($(D.CONTAINER).attr('lang')).toEqual('ja-jp');
// Result: expected '' to equal 'ja-jp'
And here is the version that does pass:
// source code
document.getElementById(D.CONTAINER.replace('#', '')).setAttribute('lang', lang);
// test
expect($(D.CONTAINER).attr('lang')).toEqual('ja-jp');
// Result: passed
If I put a debug point in the browser, the lang attribute is correctly set either way. But when running with jasmine-jquery, it's not correctly set. You can see from the passing test in the second case that the element does exist and can have the attribute set. What's going on?
OK, never mind. The problem had to do with the order of some code in beforeAll and beforeEach. When I wrote the test the second time, I moved it to a different location, which made it pass. Sorry about that.