Skip to content

Commit

Permalink
addElements option (fixes #142)
Browse files Browse the repository at this point in the history
  • Loading branch information
aFarkas committed May 3, 2014
1 parent 3ba560f commit 40df868
Show file tree
Hide file tree
Showing 10 changed files with 115 additions and 22 deletions.
2 changes: 1 addition & 1 deletion bower.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "html5shiv",
"version": "3.7.1",
"version": "3.7.2",
"main": [
"dist/html5shiv.js"
],
Expand Down
27 changes: 24 additions & 3 deletions dist/html5shiv-printshiv.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
/**
* @preserve HTML5 Shiv 3.7.1 | @afarkas @jdalton @jon_neal @rem | MIT/GPL2 Licensed
* @preserve HTML5 Shiv 3.7.2 | @afarkas @jdalton @jon_neal @rem | MIT/GPL2 Licensed
*/
;(function(window, document) {
/*jshint evil:true */
/** version */
var version = '3.7.1';
var version = '3.7.2';

/** Preset options */
var options = window.html5 || {};
Expand Down Expand Up @@ -82,6 +82,24 @@
return typeof elements == 'string' ? elements.split(' ') : elements;
}

/**
* Extends the built-in list of html5 elements
* @memberOf html5
* @param {String|Array} newElements whitespace separated list or array of new element names to shiv
* @param {Document} ownerDocument The context document.
*/
function addElements(newElements, ownerDocument) {
var elements = html5.elements;
if(typeof elements != 'string'){
elements = elements.join(' ');
}
if(typeof newElements != 'string'){
newElements = newElements.join(' ');
}
html5.elements = elements +' '+ newElements;
shivDocument(ownerDocument);
}

/**
* Returns the data associated to the given document
* @private
Expand Down Expand Up @@ -287,7 +305,10 @@
createElement: createElement,

//creates a shived documentFragment
createDocumentFragment: createDocumentFragment
createDocumentFragment: createDocumentFragment,

//extends list of elements
addElements: addElements
};

/*--------------------------------------------------------------------------*/
Expand Down
4 changes: 2 additions & 2 deletions dist/html5shiv-printshiv.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

29 changes: 25 additions & 4 deletions dist/html5shiv.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
/**
* @preserve HTML5 Shiv 3.7.1 | @afarkas @jdalton @jon_neal @rem | MIT/GPL2 Licensed
* @preserve HTML5 Shiv 3.7.2 | @afarkas @jdalton @jon_neal @rem | MIT/GPL2 Licensed
*/
;(function(window, document) {
/*jshint evil:true */
/** version */
var version = '3.7.1';
var version = '3.7.2';

/** Preset options */
var options = window.html5 || {};
Expand Down Expand Up @@ -82,7 +82,25 @@
return typeof elements == 'string' ? elements.split(' ') : elements;
}

/**
/**
* Extends the built-in list of html5 elements
* @memberOf html5
* @param {String|Array} newElements whitespace separated list or array of new element names to shiv
* @param {Document} ownerDocument The context document.
*/
function addElements(newElements, ownerDocument) {
var elements = html5.elements;
if(typeof elements != 'string'){
elements = elements.join(' ');
}
if(typeof newElements != 'string'){
newElements = newElements.join(' ');
}
html5.elements = elements +' '+ newElements;
shivDocument(ownerDocument);
}

/**
* Returns the data associated to the given document
* @private
* @param {Document} ownerDocument The document.
Expand Down Expand Up @@ -287,7 +305,10 @@
createElement: createElement,

//creates a shived documentFragment
createDocumentFragment: createDocumentFragment
createDocumentFragment: createDocumentFragment,

//extends list of elements
addElements: addElements
};

/*--------------------------------------------------------------------------*/
Expand Down
4 changes: 2 additions & 2 deletions dist/html5shiv.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "html5shiv",
"version": "3.7.0",
"version": "3.7.2",
"repository": {
"type": "git",
"url": "https://github.com/aFarkas/html5shiv.git"
Expand Down
11 changes: 10 additions & 1 deletion readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ HTML5 Shiv works as a simple drop-in solution. In most cases there is no need to

### `html5.elements` option

The `elements` option is a space separated string or array, which describes the **full** list of the elements to shiv.
The `elements` option is a space separated string or array, which describes the **full** list of the elements to shiv. see also `addElements`.

**Configuring `elements` before `html5shiv.js` is included.**

Expand Down Expand Up @@ -98,6 +98,15 @@ window.html5 = {
window.html5.shivMethods = false;
```

### `html5.addElements( newElements [, document] )`

The `html5.addElements` method extends the list of elements to shiv. The newElements argument can be a whitespace separated list or an array.

```js
//extend list of elements to shiv
html5.addElements('element content');
```

### `html5.createElement( nodeName [, document] )`

The `html5.createElement` method creates a shived element, even if `shivMethods` is set to false.
Expand Down
27 changes: 24 additions & 3 deletions src/html5shiv-printshiv.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
/**
* @preserve HTML5 Shiv 3.7.1 | @afarkas @jdalton @jon_neal @rem | MIT/GPL2 Licensed
* @preserve HTML5 Shiv 3.7.2 | @afarkas @jdalton @jon_neal @rem | MIT/GPL2 Licensed
*/
;(function(window, document) {
/*jshint evil:true */
/** version */
var version = '3.7.1';
var version = '3.7.2';

/** Preset options */
var options = window.html5 || {};
Expand Down Expand Up @@ -82,6 +82,24 @@
return typeof elements == 'string' ? elements.split(' ') : elements;
}

/**
* Extends the built-in list of html5 elements
* @memberOf html5
* @param {String|Array} newElements whitespace separated list or array of new element names to shiv
* @param {Document} ownerDocument The context document.
*/
function addElements(newElements, ownerDocument) {
var elements = html5.elements;
if(typeof elements != 'string'){
elements = elements.join(' ');
}
if(typeof newElements != 'string'){
newElements = newElements.join(' ');
}
html5.elements = elements +' '+ newElements;
shivDocument(ownerDocument);
}

/**
* Returns the data associated to the given document
* @private
Expand Down Expand Up @@ -287,7 +305,10 @@
createElement: createElement,

//creates a shived documentFragment
createDocumentFragment: createDocumentFragment
createDocumentFragment: createDocumentFragment,

//extends list of elements
addElements: addElements
};

/*--------------------------------------------------------------------------*/
Expand Down
Loading

0 comments on commit 40df868

Please sign in to comment.