Permalink
Browse files

Revert "Update info about es5-shims"

Instead of using shams, provide own implementation of getOwnPropertyNames.
See discussion of #49.
  • Loading branch information...
1 parent 6909596 commit fb8706a654ca6dedf933a9440e3cb17110688290 @ixti ixti committed Dec 3, 2012
Showing with 30 additions and 2 deletions.
  1. +2 −2 README.md
  2. +28 −0 support/browserify/30_shims.js
View
@@ -70,8 +70,8 @@ Browser support is still buggy, and mostly done to run online demo. If you
can help to improve browser compatibility and AMD support - rise pull request.
**Support of oldIEs** and some other prehistoric browsers is possible using
-[es5-shims](https://github.com/kriskowal/es5-shim). Just include shims (and
-shams) before jsyaml to use it with outdated browsers.
+[es5-shims](https://github.com/kriskowal/es5-shim). Just include shims before
+jsyaml to use it with outdated browsers.
## API
@@ -0,0 +1,28 @@
+(function () {
+ 'use strict';
+
+ // getOwnPropertyNames shim for IE7. Thanks to @Fanjita
+ // Not using es5-shams as they give more problems. See:
+ // https://github.com/nodeca/js-yaml/issues/49#issuecomment-10963606
+ if ('function' !== typeof Object.getOwnPropertyNames) {
+ Object.getOwnPropertyNames = function getOwnPropertyNames(obj) {
+ var keys = [], k;
+
+ // Only iterate the keys if we were given an object, and
+ // a special check for null, as typeof null == "object"
+ if (!!obj && 'object' === typeof obj) {
+ // Use a standard for in loop
+ for (k in obj) {
+ // A for in will iterate over members on the prototype
+ // chain as well, but Object.getOwnPropertyNames returns
+ // only those directly on the object, so use hasOwnProperty.
+ if (obj.hasOwnProperty(k)) {
+ keys.push(k);
+ }
+ }
+ }
+
+ return keys;
+ };
+ }
+}());

0 comments on commit fb8706a

Please sign in to comment.