Skip to content

Commit

Permalink
Undoes Byte Order Mark change.
Browse files Browse the repository at this point in the history
  • Loading branch information
ptrdo committed May 3, 2022
1 parent 5161ec5 commit 503f83c
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 44 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
###### This is released software. Please **[log issues](https://github.com/ptrdo/microdata-template/issues)** found.
# microdata-template `v2.3.0`
# microdata-template `v2.2.2`
An implementation of HTML template by way of the microdata mechanism.
### The Gist
This JavaScript module should simplify adding dynamic content to HTML documents while staying true to the recommendations of web standards. There are no dependencies here except the JavaScript [ECMA5 standard](http://www.ecma-international.org/ecma-262/5.1/) which enjoys [nearly universal support](http://kangax.github.io/compat-table/es5/) in modern browsers. Also, since the HTML recommendations for integral technologies such as [template](https://www.w3.org/TR/html52/semantics-scripting.html#the-template-element) and [microdata](https://www.w3.org/TR/microdata/) are variably implemented by modern browsers, this module serves as a [polyfill](https://en.wikipedia.org/wiki/Polyfill) to assure reliable results. Best of all, this methodology encourages the writing of low-dependency JavaScript and perfectly valid HTML — even within fully-functional templated markup.
Expand Down Expand Up @@ -260,11 +260,11 @@ Once instantiated in the web client code, the microdata-template can be addresse
```javascript
// In pre-ES6 implementations, the code is exposed to the global namespace:
var templater = window.MicrodataTemplate.init();
templater.getVerson(); // returns current version, e.g. "2.3.0"
templater.getVerson(); // returns current version, e.g. "2.2.2"

// In ES6 implementations, the import code does not require init()
import templater from "./path/to/microdata-template.js";
templater.getVersion(); // returns current version, e.g. "2.3.0"
templater.getVersion(); // returns current version, e.g. "2.2.2"

// Defaults are assumed, but configuration can be passed to init:
templater.init({
Expand Down
43 changes: 3 additions & 40 deletions lib/microdata-template.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
* @author Peter Sylwester
* @copyright (c)2022 Peter Sylwester
* @license MIT
* @version 2.3.0, 2022/05/03
* @version 2.2.2, 2022/05/03
* @requires "HTML5", "ECMA-262 Edition 5.1"
*
*
Expand Down Expand Up @@ -188,14 +188,6 @@
* @type {Boolean} When true, requires Microdata attributes for template.
*/
var strictStandard = false;

/**
* stripByteOrderMark removes the marking indicating UTF-8 encoding.
*
* @public via proxy
* @type {Boolean} When true, strips Byte Order Mark from incoming HTML snippets.
*/
var stripByteOrderMark = true;

/* PRIVATE UTILITIES */

Expand Down Expand Up @@ -238,13 +230,8 @@
return clone;
};

var findTemplate = function (source) {
var node, candidate;
if (stripByteOrderMark) {
node = stripBOM(source);
} else {
node = source;
}
var findTemplate = function (node) {
var candidate;
if (!strictStandard) {
return node;
} else if (isTemplate(node)) {
Expand Down Expand Up @@ -281,15 +268,6 @@
return obj === undefined ? "" : obj;
};

var stripBOM = function(buf) {
var str = buf.toString("utf-8");
if(str.charCodeAt(0) === 0xFEFF) {
return str.slice(1);
} else {
return str;
}
};

/* PRIVATE METHODS */

var clear = function (template, callback) {
Expand Down Expand Up @@ -666,9 +644,6 @@
if ("showHeritage" in config) {
strictStandard = !!config.showHeritage;
}
if ("stripByteOrderMark" in config) {
stripByteOrderMark = !!config.stripByteOrderMark;
}
}
return this;
},
Expand Down Expand Up @@ -779,18 +754,6 @@
return showHeritage;
},

getSetStripByteOrderMark: function (boo) {
/**
* @param boo {Boolean} When true, strips Byte Order Mark from incoming HTML snippets.
* @returns {Boolean} The current setting.
*/
if (arguments.length > 0) {
stripByteOrderMark = !!boo;
}

return showHeritage;
},

getSetSource: function (obj) {

if (arguments.length > 0) {
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "microdata-template",
"version": "2.3.0",
"version": "2.2.2",
"description": "An implementation of HTML template by way of the microdata mechanism.",
"keywords": [
"javascript",
Expand Down

0 comments on commit 503f83c

Please sign in to comment.