captbaritone / captbaritone/datejs
Extended Number.prototype
- Lingua principale
- JavaScript
- Stelle
- 1
- Fork
- 0
- Metriche di merge delle PR
- Nessuna PR unita negli ultimi 30g
Descrizione
```
What steps will reproduce the problem?
1. Add to nvd3/examples/stackedAreaChart.html
obtained from https://github.com/novus/nvd3.git
2. Open the html file.
What is the expected output? What do you see instead?
"TypeError: invalid 'in' operand b"
> if (k in b)
at nvd3/lib/d3.v2.js Line 3328
What version of the product are you using? On what operating system?
The latest date.js @Feb 27th 2013
The latest NVD3 @Feb 27th 2013
Firefox 19.0
Please provide any additional information below.
The variable a is 2.2 in this example.
But index k picks up "_dateElement" because date.js extends Number.prototype.
d3.interpolateObject = function(a, b) {
var i = {}, c = {}, k;
for (k in a) {
if (k in b) {
i[k] = d3_interpolateByName(k)(a[k], b[k]);
} else {
c[k] = a[k];
}
}
...
Extending prototype of primitive objects sometimes restricts users to use
hasOwnProperty() or not to use inherited properties.
Is it possible to add properties with Object.defineProperty instead?
```
Original issue reported on code.google.com by `k1assisi...@gmail.com` on 27 Feb 2013 at 5:46
Guida per i contributori
Nessuna guida per i contributori indicizzata per questo repository
Direzione di ricerca
Inizia in date.js e riproduci il problema caricandolo prima di nvd3/examples/stackedAreaChart.html in Firefox. Esamina come viene esteso Number.prototype e verifica che il grafico non fallisca più alla riga 3328 di d3.v2.js quando incontra _dateElement ereditato; l’approccio Object.defineProperty proposto dall’issue è la direzione indicata.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Valutazione
- Stack tecnologico
- javascript
- Ambito
- web-dev
- Tipo di issue
- Bug
- Difficoltà
- 3/5
- Tempo stimato
- 1-2 giorni
- Stato di attività
- Ferma
- Chiarezza
- Abbastanza chiara
- Idoneità per principianti
- 35/100