Skip to content

Instantly share code, notes, and snippets.

@amk221
Last active June 1, 2023 16:35
Show Gist options
  • Save amk221/5e38fddd37a3b4c4e5c67793d027b426 to your computer and use it in GitHub Desktop.
Save amk221/5e38fddd37a3b4c4e5c67793d027b426 to your computer and use it in GitHub Desktop.
prototype pollution
import RESTAdapter from 'ember-data/adapters/rest';
export default class extends RESTAdapter {
ajax(path, method, options) {
return {
myModels: [{
id: 1,
name: 'Model 1'
}]
};
}
}
import Controller from '@ember/controller';
export default class ApplicationController extends Controller {
appName = 'Ember Twiddle';
}
import Model from 'ember-data/model';
/*
import attr from 'ember-data/attr';
import { belongsTo, hasMany } from 'ember-data/relationships';
*/
export default class extends Model {
}
import Route from '@ember/routing/route';
import { inject } from '@ember/service';
import { A as emberA } from '@ember/array';
export default class extends Route {
@inject store;
model() {
return this.store.findAll('my-model');
}
setupController(controller, model) {
const recordArray = model;
const emberArray = emberA();
const nativeArray = [];
console.log('the arrays...');
console.log('record array', recordArray);
console.log('ember array', emberArray);
console.log('native array', nativeArray);
console.log('');
console.log('do they have kvo methods?...');
console.log('record array', !!recordArray.pushObject);
console.log('ember array', !!emberArray.pushObject);
console.log('native array', !!nativeArray.pushObject);
console.log('');
console.log('do they have kvo methods after slicing?');
console.log('record array', !!recordArray.slice().pushObject);
console.log('^ one would expect this to be false');
}
}
{
"version": "0.17.1",
"EmberENV": {
"EXTEND_PROTOTYPES": false,
"FEATURES": {},
"_TEMPLATE_ONLY_GLIMMER_COMPONENTS": false,
"_APPLICATION_TEMPLATE_WRAPPER": true,
"_JQUERY_INTEGRATION": true
},
"options": {
"use_pods": false,
"enable-testing": false
},
"dependencies": {
"jquery": "https://cdnjs.cloudflare.com/ajax/libs/jquery/3.5.1/jquery.js",
"ember": "3.18.1",
"ember-template-compiler": "3.18.1",
"ember-testing": "3.18.1"
},
"addons": {
"@glimmer/component": "1.0.0",
"ember-data": "3.18.0"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment