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

NotSupportedError: DOM Exception 9: The implementation did not support the requested type of object or operation. #917

Closed
tobyzerner opened this issue Dec 29, 2015 · 18 comments
Labels
Type: Bug For bugs and any other unexpected breakage

Comments

@tobyzerner
Copy link
Contributor

As of 270b20a, I'm getting this error in Safari (9.0.1). Chrome is unaffected.

NotSupportedError: DOM Exception 9: The implementation did not support the requested type of object or operation.

The stack trace points to createContextualFragment on this line. Looking back at the previous commit, it looks like this part was refactored and a surrounding try/catch was removed?

@dead-claudia dead-claudia added Type: Bug For bugs and any other unexpected breakage contribution welcome labels Dec 29, 2015
@dead-claudia
Copy link
Member

PRs + tests welcome!

@nianwang
Copy link

nianwang commented Jan 4, 2016

Example on Safari 9.0.2 (11601.3.9), for tag v0.2.2-rc1 (works as of v0.2.1):

var example = {
  view: function() {
    return m('div', [
      m('p', '©'),
      m('p', m.trust('©')),
      m.trust('©')
    ]);
  }
}

m.mount(document.body, example);

@dead-claudia
Copy link
Member

Is there a more minimal example?

On Mon, Jan 4, 2016, 15:53 Nian Wang notifications@github.com wrote:

Example on Safari 9.0.2 (11601.3.9), for tag v0.2.2-rc1

var example = {
view: function() {
return m('div', [
m('p', '©'),
m('p', m.trust('©')),
m.trust('©')
]);
}
}

m.mount(document.body, example);


Reply to this email directly or view it on GitHub
#917 (comment).

@iamjohnlong
Copy link
Contributor

Seems to be

document.createRange().createContextualFragment('<div>I am a div node</div>')

Isn't supported in safari even though it has the native method.

Would reverting back to a try/catch be acceptable @isiahmeadows ?

@dead-claudia
Copy link
Member

Yes, but pull the try/catch out into its own function to keep Chrome from refusing to optimize the whole function. What would be best would be to pull it out into its own independent function:

function appendTextFragment(parentElement, data) {
  try {
    parentElement.appendChild($document.createRange().createContextualFragment(data))
  } catch (e) {
    parentElement.insertAdjacentHTML("beforeend", data)
  }
}

// And in injectHTML
if (nextSibling) {
  // ...
} else {
  appendTextFragment(parentElement, data)
}

@barneycarroll
Copy link
Member

I was looking over Cito source earlier and noticed a lot of similar environment-dependent forking in frequently used functions. My ignorance of under-the-hood JIT optimisation logic leaves me somewhat unqualified, but wouldn't the best approach be to run a memoized function to test for this edge case on first execution and thereafter return the stored outcome?

Back in the day when I wrote engine-dependent implementation forks of repeatedly-invoked functions, the function reference itself would be the test, that upon execution re-assigned the reference to point to the engine-specific variation. I get the impression this completely short-circuits certain engines procedures for optimising run time, but never found a way to validate the assertion.

@iamjohnlong
Copy link
Contributor

I'm not sure how to write a test for this @isiahmeadows

#923

@dead-claudia
Copy link
Member

@barneycarroll That won't work with m.deps(), since the mock will be used from the start. Otherwise, I would've already suggested that.

@dead-claudia
Copy link
Member

Maybe once we get rid of the stupid mock, maybe it might work.

@barneycarroll
Copy link
Member

Argh. Yeah, I see that problem ;)

@dead-claudia
Copy link
Member

The only thing that even needs mocked is the XMLHttpRequest, so we aren't actually requesting anything, and can still read headers.

@pygy
Copy link
Member

pygy commented Jan 6, 2016

Don't forget requestAnimationFrame for coercing async into sync behavior (unless you want to rewrite all the async tests on top of m.hook, if it ever lands...

cheft added a commit to cheft/mithril-starter-kit that referenced this issue Jan 8, 2016
@dead-claudia
Copy link
Member

@pygy That, too. I didn't think of that. But the rest is probably best suited to die in the fires of /dev/null. 😄

@gabrieleceranto
Copy link

Hi all, i just encountered first time this bug. After some try, i found solution to let him work in safari (and other browsers too):

var range = $document.createRange();
range.selectNode(parentElement);
parentElement.appendChild(range.createContextualFragment(data));

I originally found bug in safari 5.1.10, so i guess this bug affect all recent safari versions

@dead-claudia
Copy link
Member

@gabrieleceranto It's fixed: #923

@cmnstmntmn
Copy link
Contributor

i still get it in Safari v. 9.0.2 (11601.3.9) with Mithril v0.2.2-rc.1

screen shot 2016-02-03 at 15 47 36

@tivac
Copy link
Contributor

tivac commented Feb 3, 2016

@cmnstmntmn Not surprising, v0.2.2-rc1 was cut before the fix in #923 landed.

@dead-claudia
Copy link
Member

I think @lhorie will probably cut out another -rc at some point. There's a few other things remaining (like passing more of the new test suite).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Type: Bug For bugs and any other unexpected breakage
Projects
None yet
Development

No branches or pull requests

9 participants