Sha256: 56362eeb6b684c1706e2fddd08c6f481a08e99508136ea7bbc3a681eabf2b6bc

Contents?: true

Size: 1023 Bytes

Versions: 3

Compression:

Stored size: 1023 Bytes

Contents

/*
---
 
script: Element.from.js
 
description: Methods to create elements from strings
 
license: MIT-style license.

credits: 
  - http://jdbartlett.github.com/innershiv
 
requires:
- Core/Element
 
provides: [Element.from, window.innerShiv, Elements.from, document.createFragment]
 
...
*/

document.createFragment = window.innerShiv = (function() {
	var d, r;
	
	return function(h, u) {
	  if (!d) {
			d = document.createElement('div');
			r = document.createDocumentFragment();
			/*@cc_on d.style.display = 'none';@*/
		}
		
		var e = d.cloneNode(true);
		/*@cc_on document.body.appendChild(e);@*/
		e.innerHTML = h.replace(/^\s\s*/, '').replace(/\s\s*$/, '');
		/*@cc_on document.body.removeChild(e);@*/
		
		if (u === false) return e.childNodes;
		
		var f = r.cloneNode(true), i = e.childNodes.length;
		while (i--) f.appendChild(e.firstChild);
		
		return f;
	}
}());

Element.from = function(html) {
  new Element(innerShiv(html, false)[0])
};
Elements.from = function(html) {
  new Elements(innerShiv(html))
};

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
lsd_rails-0.1.2 Packages/mootools-ext/Source/Element/Element.from.js
lsd_rails-0.1.1 Packages/mootools-ext/Source/Element/Element.from.js
lsd_rails-0.1 Packages/mootools-ext/Source/Element/Element.from.js