Prototype.js에서 SVG 요소에는 DOM 메서드가 적용되어 있지 않아 몇 줄을 수정해서 사용하고 있었다는 사실을 잊고 있었습니다. 그래서 이번에 업데이트된 1.7.1에도 적용했습니다. 이게 되면 무엇이 가능하냐고요? SVG요소를 동적으로 다루기 위한 자바스크립트를 훨씬 수월하게 작성할 수 있지요.
1.7 버전 3,041라인 부근을 다음과 같이 수정:
var elementPrototype = window.HTMLElement ? HTMLElement.prototype :
Element.prototype;
if (F.ElementExtensions) {
// Extended methods support for SVG elements by @firejune
if (window.SVGElement) {
copy(Element.Methods, SVGElement.prototype);
copy(Element.Methods.Simulated, SVGElement.prototype, true);
}
copy(Element.Methods, elementPrototype);
copy(Element.Methods.Simulated, elementPrototype, true);
}
1.7.1 버전 3,378라인 부근을 다음과 같이 수정:
var ELEMENT_PROTOTYPE = window.HTMLElement ? HTMLElement.prototype :
Element.prototype;
if (F.ElementExtensions) {
// Extended methods support for SVG elements by @firejune
if (window.SVGElement) {
mergeMethods(SVGElement.prototype, Element.Methods);
mergeMethods(SVGElement.prototype, Element.Methods.Simulated, true);
}
mergeMethods(ELEMENT_PROTOTYPE, Element.Methods);
mergeMethods(ELEMENT_PROTOTYPE, Element.Methods.Simulated, true);
}
경고: 이런 식의 패치는 혼란을 일으킬 수 있습니다.
Comments
Got something to add? You can just leave a comment.
[경준호] Prototype.js에서 SVG 요소에 DOM 메서드 적용하기: Prototype.js에서 SVG 요소에는 DOM 메서드가 적용되어 있지 않아 몇 줄을 수정해서 사용하고 있었다는 사실을 잊... http://t.co/s8m5zlqs
from twitterfeed
Your Reaction Time!