Skip to content

Commit 9ee0ee4

Browse files
committed
Version 1.0.5
1 parent c9e2c80 commit 9ee0ee4

File tree

12 files changed

+277
-270
lines changed

12 files changed

+277
-270
lines changed

MsieJavaScriptEngine.Tests/MsieJsEngineTests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ public class MsieJsEngineTests
1111
[TestFixtureSetUp]
1212
public void SetUp()
1313
{
14-
_msieJsEngine = new MsieJsEngine();
14+
_msieJsEngine = new MsieJsEngine(true);
1515
}
1616

1717
[Test]

MsieJavaScriptEngine.Tests/Properties/AssemblyInfo.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,5 +31,5 @@
3131
// You can specify all the values or you can default the Build and Revision Numbers
3232
// by using the '*' as shown below:
3333
// [assembly: AssemblyVersion("1.0.*")]
34-
[assembly: AssemblyVersion("1.0.0.0")]
35-
[assembly: AssemblyFileVersion("1.0.0.0")]
34+
[assembly: AssemblyVersion("1.0.5.0")]
35+
[assembly: AssemblyFileVersion("1.0.5.0")]

MsieJavaScriptEngine/MsieJavaScriptEngine.csproj

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,8 @@
7676
<Compile Include="Utils.cs" />
7777
</ItemGroup>
7878
<ItemGroup>
79+
<Content Include="Resources\ES5.js" />
80+
<EmbeddedResource Include="Resources\ES5.min.js" />
7981
<Content Include="Resources\msieJavaScriptEngine.js" />
8082
<EmbeddedResource Include="Resources\msieJavaScriptEngine.min.js" />
8183
</ItemGroup>
@@ -91,15 +93,11 @@
9193
<SubType>Designer</SubType>
9294
</EmbeddedResource>
9395
</ItemGroup>
94-
<ItemGroup>
95-
<Content Include="Resources\polyfills.js" />
96-
<EmbeddedResource Include="Resources\polyfills.min.js" />
97-
</ItemGroup>
9896
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
9997
<PropertyGroup>
10098
<PreBuildEvent>cd "$(ProjectDir)..\Binaries\MicrosoftAjaxMinifier\"
10199

102-
ajaxmin.exe "$(ProjectDir)Resources\polyfills.js" –out "$(ProjectDir)Resources\polyfills.min.js" –clobber
100+
ajaxmin.exe "$(ProjectDir)Resources\ES5.js" –out "$(ProjectDir)Resources\ES5.min.js" –clobber
103101
ajaxmin.exe "$(ProjectDir)Resources\msieJavaScriptEngine.js" –out "$(ProjectDir)Resources\msieJavaScriptEngine.min.js" –clobber</PreBuildEvent>
104102
</PropertyGroup>
105103
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.

MsieJavaScriptEngine/MsieJsEngine.cs

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,9 @@
1717
public sealed class MsieJsEngine : IDisposable
1818
{
1919
/// <summary>
20-
/// Name of resource, which contains a JavaScript-polyfills
20+
/// Name of resource, which contains a ECMAScript 5 Polyfill
2121
/// </summary>
22-
const string JS_POLYFILLS_RESOURCE_NAME = "MsieJavaScriptEngine.Resources.polyfills.min.js";
22+
const string ES5_POLYFILL_RESOURCE_NAME = "MsieJavaScriptEngine.Resources.ES5.min.js";
2323

2424
/// <summary>
2525
/// Name of resource, which contains a MsieJavaScript library
@@ -97,14 +97,24 @@ public sealed class MsieJsEngine : IDisposable
9797
/// <summary>
9898
/// Constructs instance of MSIE JS-engine
9999
/// </summary>
100-
public MsieJsEngine()
100+
public MsieJsEngine() : this(false)
101+
{ }
102+
103+
/// <summary>
104+
/// Constructs instance of MSIE JS-engine
105+
/// </summary>
106+
/// <param name="useEcmaScript5Polyfill">Flag for whether to use the ECMAScript 5 Polyfill</param>
107+
public MsieJsEngine(bool useEcmaScript5Polyfill)
101108
{
102109
_activeScriptSite = new ActiveScriptSite();
103110
_jsSerializer = new JavaScriptSerializer();
104111

105112
Type type = GetType();
106113

107-
ExecuteResource(JS_POLYFILLS_RESOURCE_NAME, type);
114+
if (useEcmaScript5Polyfill)
115+
{
116+
ExecuteResource(ES5_POLYFILL_RESOURCE_NAME, type);
117+
}
108118
ExecuteResource(MSIE_JAVASCRIPT_LIBRARY_RESOURCE_NAME, type);
109119
}
110120

MsieJavaScriptEngine/Properties/AssemblyInfo.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,5 +31,5 @@
3131
// You can specify all the values or you can default the Build and Revision Numbers
3232
// by using the '*' as shown below:
3333
// [assembly: AssemblyVersion("1.0.*")]
34-
[assembly: AssemblyVersion("1.0.0.0")]
35-
[assembly: AssemblyFileVersion("1.0.0.0")]
34+
[assembly: AssemblyVersion("1.0.5.0")]
35+
[assembly: AssemblyFileVersion("1.0.5.0")]
Lines changed: 234 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,234 @@
1+
/*!
2+
* ECMAScript 5 Polyfill v0.1
3+
* http://nuget.org/packages/ES5
4+
*
5+
* Copyright 2011, Douglas Crockford, Damian Edwards
6+
*/
7+
// Function.prototype.bind
8+
if (!Function.prototype.hasOwnProperty('bind')) {
9+
Function.prototype.bind = function (object) {
10+
var slice = Array.prototype.slice,
11+
func = this,
12+
args = slice.call(arguments, 1);
13+
return function () {
14+
return func.apply(object,
15+
args.concat(slice.call(arguments, 0)));
16+
};
17+
};
18+
}
19+
20+
// String.prototype.trim
21+
if (!String.prototype.hasOwnProperty('trim')) {
22+
String.prototype.trim = (function (re) {
23+
return function () {
24+
return this.replace(re, "$1");
25+
};
26+
} (/^\s*(\S*(\s+\S+)*)\s*$/));
27+
}
28+
29+
// Array.prototype.every
30+
if (!Array.prototype.hasOwnProperty('every')) {
31+
Array.prototype.every = function (fun, thisp) {
32+
var arr = this,
33+
i,
34+
length = arr.length;
35+
for (i = 0; i < length; i += 1) {
36+
if (arr.hasOwnProperty(i) &&
37+
!fun.call(thisp,
38+
arr[i], i, arr)) {
39+
return false;
40+
}
41+
}
42+
return true;
43+
};
44+
}
45+
46+
// Array.prototype.some
47+
if (!Array.prototype.hasOwnProperty('some')) {
48+
Array.prototype.some = function (fun, thisp) {
49+
var arr = this,
50+
i,
51+
length = arr.length;
52+
for (i = 0; i < length; i += 1) {
53+
if (arr.hasOwnProperty(i) &&
54+
fun.call(thisp,
55+
arr[i], i, arr)) {
56+
return true;
57+
}
58+
}
59+
return false;
60+
};
61+
}
62+
63+
// Array.prototype.filter
64+
if (!Array.prototype.hasOwnProperty('filter')) {
65+
Array.prototype.filter = function (fun, thisp) {
66+
var arr = this,
67+
i,
68+
length = arr.length,
69+
result = [],
70+
value;
71+
for (i = 0; i < length; i += 1) {
72+
if (arr.hasOwnProperty(i)) {
73+
value = arr[i];
74+
if (fun.call(thisp, value, i, arr)) {
75+
result.push(value);
76+
}
77+
}
78+
}
79+
return result;
80+
};
81+
}
82+
83+
// Array.prototype.forEach
84+
if (!Array.prototype.hasOwnProperty('forEach')) {
85+
Array.prototype.forEach = function (fun, thisp) {
86+
var arr = this,
87+
i,
88+
length = arr.length;
89+
for (i = 0; i < length; i += 1) {
90+
if (arr.hasOwnProperty(i)) {
91+
fun.call(thisp, arr[i], i, arr);
92+
}
93+
}
94+
};
95+
}
96+
97+
// Array.prototype.indexOf
98+
if (!Array.prototype.hasOwnProperty('indexOf')) {
99+
Array.prototype.indexOf = function (searchElement, fromIndex) {
100+
var arr = this,
101+
i = fromIndex || 0,
102+
length = arr.length;
103+
while (i < length) {
104+
if (arr.hasOwnProperty(i) &&
105+
arr[i] === searchElement) {
106+
return i;
107+
}
108+
i += 1;
109+
}
110+
return -1;
111+
};
112+
}
113+
114+
// Array.prototype.lastIndexOf
115+
if (!Array.prototype.hasOwnProperty('lastIndexOf')) {
116+
Array.prototype.lastIndexOf = function (searchElement, fromIndex) {
117+
var arr = this,
118+
i = fromIndex;
119+
if (typeof i !== 'number') {
120+
i = arr.length - 1;
121+
}
122+
while (i >= 0) {
123+
if (arr.hasOwnProperty(i) &&
124+
arr[i] === searchElement) {
125+
return i;
126+
}
127+
i -= 1;
128+
}
129+
return -1;
130+
};
131+
}
132+
133+
// Array.prototype.map
134+
if (!Array.prototype.hasOwnProperty('map')) {
135+
Array.prototype.map = function (fun, thisp) {
136+
var arr = this,
137+
i,
138+
length = arr.length,
139+
result = [];
140+
for (i = 0; i < length; i += 1) {
141+
if (arr.hasOwnProperty(i)) {
142+
result[i] = fun.call(thisp, arr[i], i, arr);
143+
}
144+
}
145+
return result;
146+
};
147+
}
148+
149+
// Array.prototype.reduce
150+
if (!Array.prototype.hasOwnProperty('reduce')) {
151+
Array.prototype.reduce = function (fun, initialValue) {
152+
var arr = this,
153+
i,
154+
length = arr.length;
155+
for (i = 0; i < length; i += 1) {
156+
if (arr.hasOwnProperty(i)) {
157+
initialValue = fun.call(undefined,
158+
initialValue, arr[i], i, arr);
159+
}
160+
}
161+
return initialValue;
162+
};
163+
}
164+
165+
// Array.prototype.reduceRight
166+
if (!Array.prototype.hasOwnProperty('reduceRight')) {
167+
Array.prototype.reduceRight = function (fun, initialValue) {
168+
var arr = this,
169+
i = arr.length - 1;
170+
while (i >= 0) {
171+
if (arr.hasOwnProperty(i)) {
172+
initialValue = fun.call(undefined,
173+
initialValue, arr[i], i, arr);
174+
}
175+
i -= 1;
176+
}
177+
return initialValue;
178+
};
179+
}
180+
181+
// Date.now()
182+
if (!Date.hasOwnProperty('now')) {
183+
Date.now = function () {
184+
return (new Date()).getTime();
185+
};
186+
}
187+
188+
// Date.prototype.toISOString
189+
if (!Date.prototype.hasOwnProperty('toISOString')) {
190+
Date.prototype.toISOString = function () {
191+
function f(n) {
192+
return n < 10 ? '0' + n : n;
193+
}
194+
195+
return this.getUTCFullYear() + '-' +
196+
f(this.getUTCMonth() + 1) + '-' +
197+
f(this.getUTCDate()) + 'T' +
198+
f(this.getUTCHours()) + ':' +
199+
f(this.getUTCMinutes()) + ':' +
200+
f(this.getUTCSeconds()) + 'Z';
201+
};
202+
}
203+
204+
// Array.isArray
205+
if (!Array.hasOwnProperty('isArray')) {
206+
Array.isArray = function (value) {
207+
return Object.prototype
208+
.toString.apply(value) === '[object Array]';
209+
};
210+
}
211+
212+
// Object.keys
213+
if (!Object.hasOwnProperty('keys')) {
214+
Object.keys = function (object) {
215+
var name, result = [];
216+
for (name in object) {
217+
if (Object.prototype
218+
.hasOwnProperty
219+
.call(object, name)) {
220+
result.push(name);
221+
}
222+
}
223+
return result;
224+
};
225+
}
226+
227+
// Object.create
228+
if (!Object.hasOwnProperty('create')) {
229+
Object.create = function (object) {
230+
function F() { }
231+
F.prototype = object;
232+
return new F();
233+
};
234+
}

MsieJavaScriptEngine/Resources/ES5.min.js

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

0 commit comments

Comments
 (0)