欢迎来到天天文库
浏览记录
ID:40377259
大小:67.77 KB
页数:3页
时间:2019-08-01
《dom as a rendering engine vs being the dom》由会员上传分享,免费在线阅读,更多相关内容在学术论文-天天文库。
1、DOMasarenderingengineVSBeingtheDOMStatus: DraftAuthor: igor@angularjs.orgtldr;Angularv1,Knockout,Ember,….istheformer,solutionsthatutilizeWebComponentsattheircore,likePolymerandX-Tags,arethelatter.Whileit’scommontoseeWebComponentsasastandardforjustdefiningvisualcomponents(widgets),itispo
2、ssibletousethisparadigmforconstructionofthewholewebappratherthanonlyitsindividualcomponents.WeneedtodecidewhichparadigmAngularv2shouldusebecauseit'samajordesignchoicewithmanyprosandconstoconsider.BeingDOMBeingDOMmeansthatthecorebuildingblockoftheframeworkisacustomelementthatisregistered
3、withthebrowser.It'sthebrowserthatinstantiatesandwiresupallofthecomponents.Nothingcanhappenwithoutacustomelement(Polymer’spolymer-ajax,polymer-jsonandpolymer-datastoragecustomelementsaregoodexamplesofthisapproach).Therearetypicallymanysmallelementsthatarecomposedtobuildthefinalapp.Everyc
4、omponentisisolatedfromothersandtheycancommunicateonlyviaDOMAPIs.Pros/Cons:[+]forpurposesofstylingandDOMmanipulation,there’snoneedtotreatcustomelementsasspecialbecausetheybehaveandcanbetreatedlikenativeelement[+]instantiatingacomponentiseasybutwithhiddencost(seedisadvantagesbelow)andusua
5、llydonebythebrowserautomaticallywhichcanpotentiallybefasterbutsincecomponentsstillneedtowaitfortheirdependenciestogetinstantiatedthedifferencemightnotbebigorvisibleatally[+]canleverageexistingandupcomingtoolingforDOMandwebcomponents[-]thepresentationandbusinesslogicishardnottomixbecause
6、amodelformaintainingaseparationofconcernsismissingwhichmakesitdifficulttobuildmaintainableandtestableapplications[-]instantiationofnon-trivialelementshastorelyonglobalstatetogetwireupnon-DOMdependencies,whichbreaksencapsulationofcomponents,resultinginhardreuseandtesting[?]insteadof"fixi
7、ngup"nativeelementsviadecoration,itispreferabletocreateacustomcomponentthatreplacesthem.Forsmalltweaksthisisacumbersomeapproachbecauseitisatonofworkandlooksweirdforoneofftweaks.Howeveritisabetteroptionifdoneaspartofawellalignsuiteofcomponents–e.g.customreplacementforallformelem
此文档下载收益归作者所有