allow whitelisted globals (#185)

pull/186/head
Rich-Harris 9 years ago
parent 161473a918
commit c353aa2447

@ -5,6 +5,7 @@ import isReference from '../utils/isReference.js';
import counter from './utils/counter.js';
import flattenReference from '../utils/flattenReference.js';
import namespaces from '../utils/namespaces.js';
import globalWhitelist from '../utils/globalWhitelist.js';
import getIntro from './utils/getIntro.js';
import getOutro from './utils/getOutro.js';
import visitors from './visitors/index.js';
@ -153,7 +154,7 @@ export default function generate ( parsed, source, options, names ) {
} else if ( indexes[ name ] ) {
const context = indexes[ name ];
if ( !~usedContexts.indexOf( context ) ) usedContexts.push( context );
} else {
} else if ( !globalWhitelist[ name ] ) {
dependencies.push( name );
generator.code.prependRight( node.start, `root.` );
if ( !~usedContexts.indexOf( 'root' ) ) usedContexts.push( 'root' );

@ -0,0 +1,27 @@
export default {
Array: true,
Boolean: true,
console: true,
Date: true,
decodeURI: true,
decodeURIComponent: true,
encodeURI: true,
encodeURIComponent: true,
Infinity: true,
Intl: true,
isFinite: true,
isNaN: true,
JSON: true,
Map: true,
Math: true,
NaN: true,
Number: true,
null: true,
Object: true,
parseFloat: true,
parseInt: true,
RegExp: true,
Set: true,
String: true,
undefined: true,
};

@ -0,0 +1,12 @@
export default {
data: {
x: 10
},
html: '5',
test ( assert, component, target ) {
component.set({ x: 3 });
assert.htmlEqual( target.innerHTML, '3' );
}
};
Loading…
Cancel
Save