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

Browser support? #26

Open
curioustechizen opened this issue Feb 17, 2015 · 1 comment
Open

Browser support? #26

curioustechizen opened this issue Feb 17, 2015 · 1 comment

Comments

@curioustechizen
Copy link

From the description, it looks like DOMly's pre-compiled templates will work on IE8 and above (based on info about the use of createElement, DocumentFragment and Node). Is this assumption correct? Is there a browser support list?

@lazd
Copy link
Owner

lazd commented Feb 17, 2015

DOMly uses the following DOM methods and properties:

This was brought up before and we decided to expose DOMly's compiler so you can easily extend DOMly to support IE < 9 by overriding the setTextContent method:

var domly = require('domly');

// Extend DOMly's compiler
var Compiler = function() {
  domly.Compiler.call(this);
};

Compiler.prototype = Object.create(domly.Compiler.prototype);

/**
  Support: IE < 9
  Use innerText instead of textContent if it's not available
*/
Compiler.prototype.setTextContent = function(elName, text) {
  this.pushStatement(elName+'[typeof '+elName+'.textContent === "undefined" ? "innerText" : "textContent"] = '+this.makeVariableStatement(text)+';');
};

// Export a module that uses our new compiler
module.exports = {
  Compiler: Compiler,
  compile: function(html, options) {
    var compiler = new Compiler(options);
    return compiler.compile(html);
  },
  precompile: function(html, options) {
    var compiler = new Compiler(options);
    return compiler.precompile(html);
  }
};

I'm not interested in adding support for IE < 9 to DOMly itself due to the performance hit and a general desire to push the web forward :). That said, it would be wise to add the above description to a wiki page or markdown file so it's clear to users what browsers are supported as well as how to override DOMly and integrate the overridden version when using grunt-domly and gulp-domly. I'll leave this issue open until that's done.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants