Add cross-frame compatibility to knockout.mapping#167
Open
traviskaufman wants to merge 1 commit intoSteveSanderson:masterfrom
Open
Add cross-frame compatibility to knockout.mapping#167traviskaufman wants to merge 1 commit intoSteveSanderson:masterfrom
traviskaufman wants to merge 1 commit intoSteveSanderson:masterfrom
Conversation
…h calls to getType
Author
|
What's the word on this? Is anyone maintaining this codebase currently? I see PR's open from 4 months ago |
Collaborator
|
Hi Travis, I currently don't have the time to maintain this project. There has been some discussion going on here for a potential replacement. You are also welcome to fork and extend, of course! |
Collaborator
|
I'm merging this into my fork. Btw, whitespace fixes are nice, but should be done on a separate commit (I'm guessing your editor/IDE did it automatically). |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
I was using knockout.mapping on a project where the plugin needed to be loaded within a sandboxed environment (in this case, an iframe) and noticed that it was in no way behaving as expected. This seemed to be due to two things:
exports.getTypewas looking at an object's constructor to determine what kind of object it was.instanceofoperator for type inference.Because of these, the library would not work unless loaded within the same window context as the script in which it was being used. This PR fixes that issue by using
Object.prototype.toStringto find the internal[[Class]]property of the object (as per the ECMA spec) and return the proper value from there.Note that with the current implementation
getTypewill return "object" when passednull. I'm not sure if this is the behavior that you're looking for since in most cases a client doesn't treat a "null" property the same way it treats other objects, but I left it since it's outside the scope of this PR. Happy to add it though if you guys would like! I tried it out and ran the QUnit suite and everything still passed.p.s. AWESOME knockout plugin! Made my life a whole lot easier for this project!