Backbone integration

window.WebixView = Backbone.View.extend({

tagName:"div", // <----- remove this

    var el = this.el ? $(this.el)[0] : document.body; // <-- because in that, 
                                  //this.el == "<div></div>" and couldn't be empty
                                  //and it's starts requiring jquery to work

});

Yes, you are right, this code has no sense, as with or without tagName property, a DIV will be created if any other this.el value was not provided.

In next build, we will change this line like next

		var el = window.$ ? $(this.el)[0] : this.el;

So it will use this.el always and will use jQuery only when jQuery is available on the page.

That way isn’t really good.

var el = window.$ ? $(this.el)[0] : this.el;

If I wrote some code without jquery

new WebixView({
el: document.body,

});

it wouldn’t work if I add jquery to page.

This code should work -

var el = this.el ? (typeof this.el) == “string” ? $(this.el)[0] : this.el : document.body;

if el is empty - choose document.body, if el is string - try to find element by jquery, else - el is object.

Actually it will work correctly, jQuery itself checks is incoming parameter a string or a node. So

$(document.body)[0] === document.body

Also you need to add support of Backbone.NativeView ( GitHub - akre54/Backbone.NativeView: A reference implementation of a native Backbone.View ) to make jQuery optional. Backbone depends on jQuery…

Something like that -

window.WebixView = (Backbone.NativeView ? Backbone.NativeView : Backbone.View).extend({ … });