sitelink1 | |
---|---|
sitelink2 | |
sitelink3 | |
sitelink4 | http://1 |
extra_vars4 | ko |
extra_vars5 | http://azkidev.tistory.com/entry/envjs-사용시-부족한-부분-수정 |
extra_vars6 | sitelink1 |
env.js 의 몇가지 부족한 점이 있어서 수정한 부분에 대해 포스팅..
원본:
원본 파일에서 내게 필요했던 부분 (innerHTML) 중에 잘못 구현되어 있거나, 부족했던 부분이 아래와 같이 있어서
수정하였다.
- html 에서 inline style 이 나타나지 않는 문제.
- 내용이 없는 경우 닫는 태그가 없는 문제.
- 결과물 문자열을 만드는 방식이 문자열 변수에 계속 += 연산자를 사용하는 방식이라서 비효율적으로 동작하는 문제(조금 복잡한 DOM을 다루게 되면 innerHTML을 한번 구하는데 1분 이상 걸리는 등 심각한 성능 문제가 나타남).
env.rhino.js 파일의 6404 번째 라인쯤에 있는 xhtml getter 함수를 다음과 같이 수정합니다.
get xhtml() {
//
HTMLDocument.xhtml is non-standard
// This is
exactly like Document.xml except the tagName has to be
// lower cased.
I dont like to duplicate this but its really not
// a simple
work around between xml and html serialization via
//
XMLSerializer (which uppercases html tags) and innerHTML (which
// lowercases
tags)
var ret =
"",
ns = "",
name =
(this.tagName+"").toLowerCase(),
attrs,
attrstring =
"",
i,
retArray =
[],
childRet;
// serialize
namespace declarations
if
(this.namespaceURI){
if((this ===
this.ownerDocument.documentElement) ||
(!this.parentNode)||
(this.parentNode
&&
(this.parentNode.namespaceURI
!== this.namespaceURI)))
ns = '
xmlns'+(this.prefix?(':'+this.prefix):'')+
'="'+this.namespaceURI+'"';
}
// serialize
Attribute declarations
attrs =
this.attributes;
for(i=0;i<
attrs.length;i++){
attrstring +=
" "+attrs[i].name+'="'+attrs[i].xml+'"';
}
var _toCamel =
function(name) {
if(name){
return
name.replace(/-(w)/g, function(all, letter){
return
letter.toUpperCase();
});
}
return
name;
};
if (this.style
&& this.style.length > 0) {
attrstring +=
" style="";
var so =
this.style;
var i, sl =
so.length;
for(i = 0; i
< sl; ++i){
attrstring +=
so[i] + ":" + so[_toCamel(so[i])] + ";";
}
attrstring +=
""";
}
if(this.hasChildNodes()){
// serialize
this Element
retArray.push("<");
retArray.push(name);
retArray.push(ns);
retArray.push(attrstring);
retArray.push(">");
for(i=0;i<
this.childNodes.length;i++){
childRet =
this.childNodes[i].xhtml;
retArray.push(childRet?
childRet: this.childNodes[i].xml);
}
retArray.push("</");
retArray.push(name);
retArray.push(">");
}else{
retArray.push("<");
retArray.push(name);
retArray.push(ns);
retArray.push(attrstring);
retArray.push("></");
retArray.push(name);
retArray.push(">");
}
return
retArray.join("");
}
수정한 파일:
댓글 0
번호 | 제목 | 글쓴이 | 날짜 | 조회 수 |
---|---|---|---|---|
» |
env.js 사용시 부족한 부분
![]() | 황제낙엽 | 2012.02.15 | 337 |
10 |
Rhino 와 env.js 를 사용해서 자바 서버에서 javascript 를 구동해보자
![]() | 황제낙엽 | 2012.02.15 | 401 |
9 | 라이노 (Rhino) 관련 링크 모음 | 황제낙엽 | 2008.07.21 | 383 |
8 | Rhino scopes and contexts 에 대한 문서 | 황제낙엽 | 2008.07.18 | 390 |
7 |
동적인 언어를 동적으로 호출하기
![]() | 황제낙엽 | 2008.07.14 | 277 |
6 | How to use Rhino to script Java classes. | 황제낙엽 | 2008.07.14 | 467 |
5 | Java 버전의 JavaScript 엔진 라이노 (Rhino) | 황제낙엽 | 2008.07.14 | 461 |
4 |
SpiderMonkey 를 이용한 개발 일기
![]() | 황제낙엽 | 2008.07.14 | 264 |
3 | JSAPI User Guide | 황제낙엽 | 2008.07.14 | 413 |
2 | State of ECMAScript 4 ('07 12) | 황제낙엽 | 2008.07.14 | 405 |
1 | SpiderMonkey와 Tamarin | 황제낙엽 | 2008.07.14 | 409 |