Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUGFIX lts] Prevent <base target="_parent"> from erroring in HistoryLocation #19059

Merged
merged 1 commit into from Jul 29, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Expand Up @@ -77,7 +77,7 @@ export default class HistoryLocation extends EmberObject implements EmberLocatio

let base = document.querySelector('base');
let baseURL: string | null = '';
if (base) {
if (base !== null && base.hasAttribute('href')) {
baseURL = base.getAttribute('href');
}

Expand Down
Expand Up @@ -97,6 +97,42 @@ moduleFor(
location.initState();
}

['@test <base> with href sets `baseURL`'](assert) {
assert.expect(1);

let base = document.createElement('base');
base.setAttribute('href', '/foo/');

document.head.appendChild(base);

try {
createLocation();
location.initState();

assert.strictEqual(location.get('baseURL'), '/foo/');
} finally {
document.head.removeChild(base);
}
}

['@test <base> without href is ignored'](assert) {
assert.expect(1);

let base = document.createElement('base');
base.setAttribute('target', '_parent');

document.head.appendChild(base);

try {
createLocation();
location.initState();

assert.strictEqual(location.get('baseURL'), '');
} finally {
document.head.removeChild(base);
}
}

['@test base URL is removed when retrieving the current pathname'](assert) {
assert.expect(1);

Expand Down