nprapps/pym.js — pull request #44 by jugglinmike (2014-06-18 15:32:45+00:00)
Title: Introduce 'autoinit' feature

As originally proposed in issue #41:

> My use-case for pym.js is similar to the motivating example in the project website (embedding an iframe in a CMS document), but I have an additional restriction: the CMS actively scrubs in-line JavaScript. I would like to instruct pym.js to automatically instantiate a parent connection on iframes that opt-in to the functionality.

There, @onyxfish share the following feedback:

> [...] it seems like the `data-pym-autoinit` property shouldn't be necessary. Ideally there would just be something on each div identifying what pym should do with it.

That proparty is a bit of an optimization; it allows pym to skip the automatic initialization code path for all the users that don't need it. On the other hand, it makes the feature a little harder to discover/use. I'm happy to remove it; I just wanted to make sure the trade off was understood first. Let me know!

Commit message:

> Enable the automatic creation of iframes when the script tag which
> included Pym.js contains a `data-pym-autoinit` attribute. Ensure that
> duplicate iframes are not created in cases where pym.js is included more
> than once in the same document.