Skip to content

Commit 3cd74e5

Browse files
committed
Use Object.create(null) for maps.
This prevents inadvertent leakage of `Object` properties into the map.
1 parent 451ce6b commit 3cd74e5

File tree

5 files changed

+5
-5
lines changed

5 files changed

+5
-5
lines changed

build.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@
113113
${license.text}
114114
*/
115115
/* Version v@VERSION@, Build time: ${RIGHT_NOW} */
116-
var parserlib = {};
116+
var parserlib = Object.create(null);
117117
(function(){
118118
</header>
119119
<!--<filelist dir="${src.dir}/util" files="EventTarget.js, StringReader.js, TokenStream.js"/> -->

src/css/TokenStream.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ function isIdentStart(c){
4040

4141
function mix(receiver, supplier){
4242
for (var prop in supplier){
43-
if (supplier.hasOwnProperty(prop)){
43+
if (Object.prototype.hasOwnProperty.call(supplier, prop)){
4444
receiver[prop] = supplier[prop];
4545
}
4646
}

src/css/Tokens.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,7 @@ var Tokens = [
180180
(function(){
181181

182182
var nameMap = [],
183-
typeMap = {};
183+
typeMap = Object.create(null);
184184

185185
Tokens.UNKNOWN = -1;
186186
Tokens.unshift({name:"EOF"});

src/util/EventTarget.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ function EventTarget(){
1313
* @property _listeners
1414
* @private
1515
*/
16-
this._listeners = {};
16+
this._listeners = Object.create(null);
1717
}
1818

1919
EventTarget.prototype = {

src/util/TokenStreamBase.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ function TokenStreamBase(input, tokenData){
6565
TokenStreamBase.createTokenData = function(tokens){
6666

6767
var nameMap = [],
68-
typeMap = {},
68+
typeMap = Object.create(null),
6969
tokenData = tokens.concat([]),
7070
i = 0,
7171
len = tokenData.length+1;

0 commit comments

Comments
 (0)