joestelmach / laconic Goto Github PK
View Code? Open in Web Editor NEWSane DOM Generation
License: MIT License
Sane DOM Generation
License: MIT License
Hi, I'm looking at the best way to expand & contract HTML tables in JavaScript: http://stackoverflow.com/questions/10249939/tools-to-column-rows-on-html5-tables
Would it be easy for me (not great JS programmer) to extend laconic to read the DOM also, or what existing library do you recommend paring with loconic that is fast & is as easy to use?
Thanks for making a great JavaScript tool!
IE 7 and 8 have no idea how to set the name attribute on elements once they have been created, this means that you can never create an element with a name attribute via laconic.
The workaround for this is a bit unfortunate (and this version relies on jQuery):
//http://webbugtrack.blogspot.com.au/2007/10/bug-235-createelement-is-broken-in-ie.html
var oldIE = $.browser.msie && $.browser.version < 9,
el;
if(oldIE && arguments[1] && typeof arguments[1] === 'object' && arguments[1].name){
el = document.createElement('<' + arguments[0] + ' name="' + arguments[1].name + '">');
}else{
// create a new element of the requested type
el = document.createElement(arguments[0]);
}
There may be other attributes that IE cannot set after creating an element, which could be solved by looping over the settings and injecting them into that string.
how would i achieve the following…
<h1>
20<sup>th</sup> Century Fox
</h1>
Trying to pass an array of elements with no attribute object causes "String contains an invalid character" error (tested on firefox). It appears that this is because it tries to use the array as the attribute object.
Example JSFiddle: http://jsfiddle.net/XZN8X/16/
$(function() {
// Passing in individual elements works.
var works =
$('#works').html(works);
// Passing in that same array with an empty attributes object works.
var worksWithExplicitAttributes = $.el.div({}, [$.el.p("A2"), $.el.p("B2")]);
$('#worksWithExplicitAttributes').html(worksWithExplicitAttributes);
// Passing in an array of those elements fails.
var fails = $.el.div([$.el.p("A3"), $.el.p("B3")]);
$('#fails').html(fails);
})
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.