-
Notifications
You must be signed in to change notification settings - Fork 16
IE less then 8 shim algorithm
termi1uc1 edited this page Feb 1, 2012
·
10 revisions
#IE < 8 shim algorithm
-
In your implementation of
Object.defineProperty(obj, ...)for IE make sure you check for theielt8flag and set getters and setters asobj["get"/"set" + propertyName]... if(Object.defineProperty.ielt8) { obj["get" + propertyName] = getter; obj["set" + propertyName] = setter; } ... -
Set
Object.defineProperty.ielt8=true; -
Use HTC technique for shim. Add
styleelement with content:* { behavior : shim.htc } -
In HTC file:
<PUBLIC:PROPERTY NAME="propertyName" GET="getter_propertyName" PUT="setter_propertyName" /> <SCRIPT> var proto = Element.prototype; var getter_propertyName = proto.getpropertyName; var setter_propertyName = proto.setpropertyName; </SCRIPT>
-
Create fake
Node = {}andNode.prototype = {ielt8 : true}for IE < 8. You can useielt8flag for detect purpose -
Define functions as usual:
Object.defineProperty(Node.prototype, "someFunction", { value : someFunction }) // or Node.prototype.someFunction = someFunction; -
Use HTC technique for shim. Add
styleelement with content:* { behavior : shim.htc } -
In HTC file:
<SCRIPT> var Node_proto=window.Node.prototype; if(!this.someFunction)this.someFunction = Node_proto.someFunction; </SCRIPT>
-
Create lightweight
htcfile. First line in file:<PUBLIC:COMPONENT lightWeight="true"> -
TODO::