prototype.js 1.5.1に対応してみる
2007-05-02


気が付いたら

prototype.jsが1.5.1になっていた。

なんとなく、prototype.jsを使えるようにで試した感じで1.5.1を読み込ませてみたら山ほどエラーがでるでる。

UAの判別を事前に行って、メソッドの組み立てそのものも最適化しているのか、読み込み時に実行されるコードが増えていたみたい。

なんとか対応してみました

try & error で何とか以下のコードに落ち着いたし。

// prototype.jsのためのダミー宣言(v1.5.0/1.5.1対応版)
var window = {
        Element : null,
        ActiveXObject : ActiveXObject
};

document = window.document = {
        getElementById : function() {},
        getElementsByName : function() {},
        getElementsByTagName : function() {},
        createElement : function() {
                return {
                        "__proto__" : {},
                        appendChild : function() {}
                };
        },
        createTextNode : function() {},
        documentElement : null,
        body : null
};

navigator = window.navigator = {
        appVersion : "",
        userAgent : ""
};

HTMLElement = window.HTMLElement = { prototype : {} };
HTMLFormElement = window.HTMLFormElement = { prototype : {} };
HTMLInputElement = window.HTMLInputElement = { prototype : {} };
HTMLTextAreaElement = window.HTMLTextAreaElement = { prototype : {} };
HTMLSelectElement = window.SelectElement = { prototype : {} };
考えてみると、こうまでして新しいverに対応しなくてもよかった気が...
[JavaScript]
[WSH]

コメント(全0件)
コメントをする


記事を書く
powered by ASAHIネット