4

I found in the index.html of the TodoMVC example the following line of code:

<html lang="en" data-framework="backbonejs">

Does anybody know for this data element is used for?

PrestaShopDeveloper
  • 3,110
  • 3
  • 21
  • 30
SBel
  • 3,315
  • 6
  • 29
  • 47

1 Answers1

6

It has nothing to do with dependencies of TodoMVC. The only purpose of this attribute is to allow appending of the side-panel with links to the documentation for a specific framework a particular version of TodoMVC example is built with. This is how it's done:

if (!framework && document.querySelector('[data-framework]')) {
  framework = document.querySelector('[data-framework]')
      .getAttribute('data-framework');
}
// ...
if (template && learnJSON[framework]) {
  this.frameworkJSON = learnJSON[framework];
  this.template = template;

  this.append();
}       

Learn.prototype.append = function () {
  var aside = document.createElement('aside');
  aside.innerHTML = _.template(this.template, this.frameworkJSON);
  aside.className = 'learn';

  // Localize demo links
  var demoLinks = aside.querySelectorAll('.demo-link');
  Array.prototype.forEach.call(demoLinks, function (demoLink) {
    demoLink.setAttribute('href', findRoot() + demoLink.getAttribute('href'));
  });

  document.body.className = (document.body.className + ' learn-bar').trim();
  document.body.insertAdjacentHTML('afterBegin', aside.outerHTML);
};
raina77ow
  • 103,633
  • 15
  • 192
  • 229