Skip to content

Commit 40df868

Browse files
author
aFarkas
committed
addElements option (fixes #142)
1 parent 3ba560f commit 40df868

File tree

10 files changed

+115
-22
lines changed

10 files changed

+115
-22
lines changed

bower.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "html5shiv",
3-
"version": "3.7.1",
3+
"version": "3.7.2",
44
"main": [
55
"dist/html5shiv.js"
66
],

dist/html5shiv-printshiv.js

Lines changed: 24 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
/**
2-
* @preserve HTML5 Shiv 3.7.1 | @afarkas @jdalton @jon_neal @rem | MIT/GPL2 Licensed
2+
* @preserve HTML5 Shiv 3.7.2 | @afarkas @jdalton @jon_neal @rem | MIT/GPL2 Licensed
33
*/
44
;(function(window, document) {
55
/*jshint evil:true */
66
/** version */
7-
var version = '3.7.1';
7+
var version = '3.7.2';
88

99
/** Preset options */
1010
var options = window.html5 || {};
@@ -82,6 +82,24 @@
8282
return typeof elements == 'string' ? elements.split(' ') : elements;
8383
}
8484

85+
/**
86+
* Extends the built-in list of html5 elements
87+
* @memberOf html5
88+
* @param {String|Array} newElements whitespace separated list or array of new element names to shiv
89+
* @param {Document} ownerDocument The context document.
90+
*/
91+
function addElements(newElements, ownerDocument) {
92+
var elements = html5.elements;
93+
if(typeof elements != 'string'){
94+
elements = elements.join(' ');
95+
}
96+
if(typeof newElements != 'string'){
97+
newElements = newElements.join(' ');
98+
}
99+
html5.elements = elements +' '+ newElements;
100+
shivDocument(ownerDocument);
101+
}
102+
85103
/**
86104
* Returns the data associated to the given document
87105
* @private
@@ -287,7 +305,10 @@
287305
createElement: createElement,
288306

289307
//creates a shived documentFragment
290-
createDocumentFragment: createDocumentFragment
308+
createDocumentFragment: createDocumentFragment,
309+
310+
//extends list of elements
311+
addElements: addElements
291312
};
292313

293314
/*--------------------------------------------------------------------------*/

dist/html5shiv-printshiv.min.js

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/html5shiv.js

Lines changed: 25 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
/**
2-
* @preserve HTML5 Shiv 3.7.1 | @afarkas @jdalton @jon_neal @rem | MIT/GPL2 Licensed
2+
* @preserve HTML5 Shiv 3.7.2 | @afarkas @jdalton @jon_neal @rem | MIT/GPL2 Licensed
33
*/
44
;(function(window, document) {
55
/*jshint evil:true */
66
/** version */
7-
var version = '3.7.1';
7+
var version = '3.7.2';
88

99
/** Preset options */
1010
var options = window.html5 || {};
@@ -82,7 +82,25 @@
8282
return typeof elements == 'string' ? elements.split(' ') : elements;
8383
}
8484

85-
/**
85+
/**
86+
* Extends the built-in list of html5 elements
87+
* @memberOf html5
88+
* @param {String|Array} newElements whitespace separated list or array of new element names to shiv
89+
* @param {Document} ownerDocument The context document.
90+
*/
91+
function addElements(newElements, ownerDocument) {
92+
var elements = html5.elements;
93+
if(typeof elements != 'string'){
94+
elements = elements.join(' ');
95+
}
96+
if(typeof newElements != 'string'){
97+
newElements = newElements.join(' ');
98+
}
99+
html5.elements = elements +' '+ newElements;
100+
shivDocument(ownerDocument);
101+
}
102+
103+
/**
86104
* Returns the data associated to the given document
87105
* @private
88106
* @param {Document} ownerDocument The document.
@@ -287,7 +305,10 @@
287305
createElement: createElement,
288306

289307
//creates a shived documentFragment
290-
createDocumentFragment: createDocumentFragment
308+
createDocumentFragment: createDocumentFragment,
309+
310+
//extends list of elements
311+
addElements: addElements
291312
};
292313

293314
/*--------------------------------------------------------------------------*/

dist/html5shiv.min.js

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "html5shiv",
3-
"version": "3.7.0",
3+
"version": "3.7.2",
44
"repository": {
55
"type": "git",
66
"url": "https://github.com/aFarkas/html5shiv.git"

readme.md

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ HTML5 Shiv works as a simple drop-in solution. In most cases there is no need to
4444

4545
### `html5.elements` option
4646

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

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

@@ -98,6 +98,15 @@ window.html5 = {
9898
window.html5.shivMethods = false;
9999
```
100100

101+
### `html5.addElements( newElements [, document] )`
102+
103+
The `html5.addElements` method extends the list of elements to shiv. The newElements argument can be a whitespace separated list or an array.
104+
105+
```js
106+
//extend list of elements to shiv
107+
html5.addElements('element content');
108+
```
109+
101110
### `html5.createElement( nodeName [, document] )`
102111

103112
The `html5.createElement` method creates a shived element, even if `shivMethods` is set to false.

src/html5shiv-printshiv.js

Lines changed: 24 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
/**
2-
* @preserve HTML5 Shiv 3.7.1 | @afarkas @jdalton @jon_neal @rem | MIT/GPL2 Licensed
2+
* @preserve HTML5 Shiv 3.7.2 | @afarkas @jdalton @jon_neal @rem | MIT/GPL2 Licensed
33
*/
44
;(function(window, document) {
55
/*jshint evil:true */
66
/** version */
7-
var version = '3.7.1';
7+
var version = '3.7.2';
88

99
/** Preset options */
1010
var options = window.html5 || {};
@@ -82,6 +82,24 @@
8282
return typeof elements == 'string' ? elements.split(' ') : elements;
8383
}
8484

85+
/**
86+
* Extends the built-in list of html5 elements
87+
* @memberOf html5
88+
* @param {String|Array} newElements whitespace separated list or array of new element names to shiv
89+
* @param {Document} ownerDocument The context document.
90+
*/
91+
function addElements(newElements, ownerDocument) {
92+
var elements = html5.elements;
93+
if(typeof elements != 'string'){
94+
elements = elements.join(' ');
95+
}
96+
if(typeof newElements != 'string'){
97+
newElements = newElements.join(' ');
98+
}
99+
html5.elements = elements +' '+ newElements;
100+
shivDocument(ownerDocument);
101+
}
102+
85103
/**
86104
* Returns the data associated to the given document
87105
* @private
@@ -287,7 +305,10 @@
287305
createElement: createElement,
288306

289307
//creates a shived documentFragment
290-
createDocumentFragment: createDocumentFragment
308+
createDocumentFragment: createDocumentFragment,
309+
310+
//extends list of elements
311+
addElements: addElements
291312
};
292313

293314
/*--------------------------------------------------------------------------*/

0 commit comments

Comments
 (0)