Skip to content
This repository has been archived by the owner on Sep 20, 2019. It is now read-only.

Commit

Permalink
Merge pull request #191 from mereskin/fix/baseURI-in-safari-7
Browse files Browse the repository at this point in the history
Fixes exception, thrown in Safari 7 on iPad
  • Loading branch information
John Messerly committed Feb 11, 2015
2 parents 5e7a380 + 51d795e commit ddb35fb
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/HTMLImports/importer.js
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,10 @@ function isLinkRel(elt, rel) {
return elt.localName === 'link' && elt.getAttribute('rel') === rel;
}

function hasBaseURIAccessor(doc) {
return !! Object.getOwnPropertyDescriptor(doc, 'baseURI');
}

function makeDocument(resource, url) {
// create a new HTML document
var doc = document.implementation.createHTMLDocument(IMPORT_LINK_TYPE);
Expand All @@ -128,7 +132,7 @@ function makeDocument(resource, url) {
var base = doc.createElement('base');
base.setAttribute('href', url);
// add baseURI support to browsers (IE) that lack it.
if (!doc.baseURI) {
if (!doc.baseURI && !hasBaseURIAccessor(doc)) {
// Use defineProperty since Safari throws an exception when using assignment.
Object.defineProperty(doc, 'baseURI', {value:url});
}
Expand Down

0 comments on commit ddb35fb

Please sign in to comment.